<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Flow: net_flow/node.cpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">Flow<span id="projectnumber">&#160;2.0.0</span>
   </div>
   <div id="projectbrief">Flow project: Full implementation reference.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_460afd45d0ec637b1427e0e06a6fbcf7.html">net_flow</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle"><div class="title">node.cpp</div></div>
</div><!--header-->
<div class="contents">
<a href="node_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="comment">/* Flow</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="comment"> * Copyright 2023 Akamai Technologies, Inc.</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span><span class="comment"> *</span></div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="comment"> * Licensed under the Apache License, Version 2.0 (the</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="comment"> * &quot;License&quot;); you may not use this file except in</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="comment"> * compliance with the License.  You may obtain a copy</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="comment"> * of the License at</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span><span class="comment"> *</span></div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="comment"> *   https://www.apache.org/licenses/LICENSE-2.0</span></div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="comment"> *</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="comment"> * Unless required by applicable law or agreed to in</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span><span class="comment"> * writing, software distributed under the License is</span></div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span><span class="comment"> * distributed on an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR</span></div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span><span class="comment"> * CONDITIONS OF ANY KIND, either express or implied.</span></div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span><span class="comment"> * See the License for the specific language governing</span></div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="comment"> * permissions and limitations under the License. */</span></div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="comment"></span> </div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span><span class="comment">/// @file</span></div>
<div class="line"><a id="l00019" name="l00019"></a><span class="lineno">   19</span><span class="comment"></span><span class="preprocessor">#include &quot;<a class="code" href="node_8hpp.html">flow/net_flow/node.hpp</a>&quot;</span></div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno">   20</span><span class="preprocessor">#include &quot;<a class="code" href="endpoint_8hpp.html">flow/net_flow/endpoint.hpp</a>&quot;</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno">   21</span><span class="preprocessor">#include &quot;<a class="code" href="sched__task_8hpp.html">flow/util/sched_task.hpp</a>&quot;</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno">   22</span><span class="preprocessor">#include &lt;algorithm&gt;</span></div>
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno">   23</span><span class="preprocessor">#include &lt;limits&gt;</span></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span> </div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="keyword">namespace </span><a class="code hl_namespace" href="namespaceflow_1_1net__flow.html">flow::net_flow</a></div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno">   26</span>{</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno">   27</span><span class="comment">// Static initializations.</span></div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno">   28</span> </div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno">   29</span><span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow.html#a48799f1263cdeedec125be51a3db2b79">Fine_duration</a> <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a2f97b363281b79ef4f399789442c84de">Node::S_REGULAR_INFREQUENT_TASKS_PERIOD</a> = boost::chrono::seconds(1); <span class="comment">// Infrequent enough CPU-wise.</span></div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno">   30</span> </div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span><span class="comment">// Note that they&#39;re references, not copies.  Otherwise non-deterministic static initialization order would screw us.</span></div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span><span class="keyword">const</span> <span class="keywordtype">size_t</span>&amp; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a1ecd7c03349fcb26b9692d300a759463">Node::S_NUM_PORTS</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Port__space.html#af0c60ec4732021d52a19e5d2f6dc8b35">Port_space::S_NUM_PORTS</a>;</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno">   33</span><span class="keyword">const</span> <span class="keywordtype">size_t</span>&amp; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aa1b913c5c759a465a9fcaa637ddaea99">Node::S_NUM_SERVICE_PORTS</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Port__space.html#ad93c0b6f23be37efe0f96ab066ff9bf8">Port_space::S_NUM_SERVICE_PORTS</a>;</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno">   34</span><span class="keyword">const</span> <span class="keywordtype">size_t</span>&amp; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a7aadcad6c19587cd0d788570194b2afd">Node::S_NUM_EPHEMERAL_PORTS</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Port__space.html#a06fb009aafc77f75241f721734fe3cc4">Port_space::S_NUM_EPHEMERAL_PORTS</a>;</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno">   35</span><span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1net__flow.html#a079d8cd87a68d1c5f04c6bce71f0061d">flow_port_t</a>&amp; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a96b593d90c246cb2e35fc6a0834e6876">Node::S_FIRST_SERVICE_PORT</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Port__space.html#a6d07833521960b2f90806bfa7728cfd8">Port_space::S_FIRST_SERVICE_PORT</a>;</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span><span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1net__flow.html#a079d8cd87a68d1c5f04c6bce71f0061d">flow_port_t</a>&amp; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aa1d1021e099c70c1a6e192e65f86debf">Node::S_FIRST_EPHEMERAL_PORT</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Port__space.html#ab9a614b67638cbd9526eb82033a53352">Port_space::S_FIRST_EPHEMERAL_PORT</a>;</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno">   38</span><span class="comment">// Implementations.  For Node code pertaining to individual Server_sockets and Peer_sockets see their .cpp files.</span></div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno">   39</span> </div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#acd93ba39d6a9cdee60c2ad7da1085902">   40</a></span><a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#acd93ba39d6a9cdee60c2ad7da1085902">Node::Node</a>(<a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>* logger_ptr, <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">util::Udp_endpoint</a>&amp; low_lvl_endpoint, <a class="code hl_class" href="classflow_1_1net__flow_1_1Net__env__simulator.html">Net_env_simulator</a>* net_env_sim,</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>           <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>* err_code, <span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; opts) :</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span>  log::Log_context(this_thread_init_logger_setup(<span class="stringliteral">&quot;&quot;</span>, logger_ptr),</div>
<div class="line"><a id="l00043" name="l00043"></a><span class="lineno">   43</span>                   <a class="code hl_enumeration" href="namespaceflow.html#a3938730ab4b89daf13d027a5f620e7ce">Flow_log_component</a>::S_NET_FLOW),</div>
<div class="line"><a id="l00044" name="l00044"></a><span class="lineno">   44</span>  <span class="comment">/* Take the given Node_options set and copy it into our stored global options.  (Note the default</span></div>
<div class="line"><a id="l00045" name="l00045"></a><span class="lineno">   45</span><span class="comment">   * is Node_options().)  The default is safe, but if they actually are providing a custom set of</span></div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span><span class="comment">   * options, then we must validate before accepting.  This may result in a validation error.</span></div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span><span class="comment">   * If !err_code, then it&#39;ll throw exception right here.  If err_code, then it will set *err_code,</span></div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno">   48</span><span class="comment">   * so we check for it inside the constructor body and exit. */</span></div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno">   49</span>  m_opts(validate_options(opts, true, err_code)),</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno">   50</span>  m_net_env_sim(net_env_sim), <span class="comment">// Note this is a smart pointer taking over a raw pointer (we did advertise owning it).</span></div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno">   51</span>  m_low_lvl_sock(m_task_engine), <span class="comment">// Blank (unbound) UDP socket.</span></div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>  m_packet_data(logger_ptr),</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span>  m_ports(logger_ptr),</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno">   54</span>  m_seq_num_generator(logger_ptr),</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno">   55</span>  m_sock_events(<a class="code hl_class" href="classflow_1_1net__flow_1_1Event__set.html">Event_set</a>::empty_ev_type_to_socks_map()),</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno">   56</span>  <span class="comment">// Set up future object used to wait for m_event_loop_ready to become success or failure.</span></div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno">   57</span>  m_event_loop_ready_result(m_event_loop_ready.get_future()),</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno">   58</span>  <span class="comment">/* Set up a signal set object; this is a no-op until we .add() signals to it (which we may or may not do).</span></div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span><span class="comment">   * Whether we do or not is more significant than merely whether whatever handler we&#39;d later register</span></div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span><span class="comment">   * via m_signal_set.async_wait() will be called; if we .add() zero signals, then IF some non-boost.asio</span></div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno">   61</span><span class="comment">   * signal handler is currently registered (such as the default OS handler; or the user&#39;s non-boost.asio handler)</span></div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno">   62</span><span class="comment">   * (or will be registered in the future) will continue to work undisturbed.  If, however, we .add() one or more</span></div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno">   63</span><span class="comment">   * signals (or, equivalently, list 1 or more signal numbers right here in the constructor call),</span></div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span><span class="comment">   * then we will REPLACE such non-boost.asio handlers with boost.asio&#39;s mechanism.  (This behavior is</span></div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span><span class="comment">   * explicitly documented in boost.asio docs.)  Therefore we must be careful not to mindlessly .add() handler(s),</span></div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno">   66</span><span class="comment">   * and/or (equivalently) list 1 or more signal numbers in this constructor call here.  The choice will be left to</span></div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno">   67</span><span class="comment">   * later code which will .add() or not .add() deliberately. */</span></div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno">   68</span>  m_signal_set(m_task_engine),</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno">   69</span>  <span class="comment">// Spawn new thread W; in it execute this-&gt;worker_run(low_lvl_endpoint).  low_lvl_endpoint is copied.</span></div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>  m_worker(&amp;<a class="code hl_class" href="classflow_1_1net__flow_1_1Node.html">Node</a>::worker_run, this, low_lvl_endpoint)</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span>{</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno">   72</span>  <span class="keyword">using </span><a class="code hl_class" href="classflow_1_1error_1_1Runtime__error.html">flow::error::Runtime_error</a>;</div>
<div class="line"><a id="l00073" name="l00073"></a><span class="lineno">   73</span> </div>
<div class="line"><a id="l00074" name="l00074"></a><span class="lineno">   74</span>  <span class="comment">// We are in thread U.</span></div>
<div class="line"><a id="l00075" name="l00075"></a><span class="lineno">   75</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Starting flow::Node [&quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>) &lt;&lt; <span class="stringliteral">&quot;].&quot;</span>);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span>  <span class="comment">// validate_options() may have already detected an error; then it would&#39;ve thrown if (!err_code); else: Check it.</span></div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno">   79</span>  <span class="keywordflow">if</span> (err_code &amp;&amp; (*err_code))</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno">   80</span>  {</div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno">   81</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Cannot start Node due to above error.&quot;</span>);</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span>  }</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno">   84</span> </div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno">   85</span>  <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> our_err_code; <span class="comment">// Prepare this if they passed in no Error_code, so we can throw exception.</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno">   86</span>  err_code || (err_code = &amp;our_err_code);</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno">   87</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;\n\n&quot;</span> &lt;&lt; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a159b9c2b9a8a969f5e3715341c433aec">options</a>()); <span class="comment">// Log initial option values.  Once per Node, so it&#39;s not too verbose.</span></div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span> </div>
<div class="line"><a id="l00090" name="l00090"></a><span class="lineno">   90</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Just launched Flow worker thread [T&quot;</span> &lt;&lt; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">m_worker</a>.get_id() &lt;&lt; <span class="stringliteral">&quot;].  &quot;</span></div>
<div class="line"><a id="l00091" name="l00091"></a><span class="lineno">   91</span>                <span class="stringliteral">&quot;Waiting for it to report startup success or failure.&quot;</span>);</div>
<div class="line"><a id="l00092" name="l00092"></a><span class="lineno">   92</span> </div>
<div class="line"><a id="l00093" name="l00093"></a><span class="lineno">   93</span>  <span class="comment">// Now wait around (probably not long) until thread W tells us either initialization success or failure.</span></div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a61f87144f19e908ffb981f3bff91938e">m_event_loop_ready_result</a>.wait();</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span>  *err_code = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a61f87144f19e908ffb981f3bff91938e">m_event_loop_ready_result</a>.get();</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span>  <span class="keywordflow">if</span> (*err_code)</div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno">   97</span>  {</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Flow worker thread [T&quot;</span> &lt;&lt; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">m_worker</a>.get_id() &lt;&lt; <span class="stringliteral">&quot;] reported to me it failed to initialize: &quot;</span></div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno">   99</span>                     <span class="stringliteral">&quot;[&quot;</span> &lt;&lt; *err_code &lt;&lt; <span class="stringliteral">&quot;] [&quot;</span> &lt;&lt; err_code-&gt;message() &lt;&lt; <span class="stringliteral">&quot;].&quot;</span>);</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>  }</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno">  101</span>  <span class="keywordflow">else</span></div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>  {</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno">  103</span>    <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Flow worker thread [T&quot;</span> &lt;&lt; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">m_worker</a>.get_id() &lt;&lt; <span class="stringliteral">&quot;] reports to me it is ready for work.&quot;</span>);</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>  }</div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno">  105</span>  <span class="comment">// m_task_engine.stopped() can now be reliably used to tell whether the Node (i.e., thread W) is running.</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span> </div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span>  <span class="keywordflow">if</span> (our_err_code) <span class="comment">// Throw exception if there is an error, and they passed in no Error_code.</span></div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno">  108</span>  {</div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>    <span class="keywordflow">throw</span> Runtime_error(our_err_code, <a class="code hl_define" href="util__fwd_8hpp.html#a0cc4c82ac54e53b7a8a2431b66ff30df">FLOW_UTIL_WHERE_AM_I_STR</a>());</div>
<div class="line"><a id="l00110" name="l00110"></a><span class="lineno">  110</span>  }</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>} <span class="comment">// Node::Node()</span></div>
<div class="line"><a id="l00112" name="l00112"></a><span class="lineno">  112</span> </div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#aa894fd58b246c2a8d6c7c7d25a8748cb">  113</a></span><a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>* <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aa894fd58b246c2a8d6c7c7d25a8748cb">Node::this_thread_init_logger_setup</a>(<span class="keyword">const</span> std::string&amp; thread_type, <a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>* logger_ptr)</div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno">  114</span>{</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>  <span class="keyword">using </span><a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>;</div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno">  116</span>  <span class="keyword">using </span><a class="code hl_function" href="namespaceflow_1_1log.html#aaaaa1dcbf7c8dc99aceb2b6c217187fc">log::beautify_chrono_logger_this_thread</a>;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>  <span class="keyword">using </span>std::string;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno">  118</span>  <span class="keyword">using </span>std::hex;</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span> </div>
<div class="line"><a id="l00120" name="l00120"></a><span class="lineno">  120</span>  <span class="keywordflow">if</span> (!logger_ptr)</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>  {</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>    logger_ptr = <a class="code hl_function" href="classflow_1_1log_1_1Log__context.html#af4db395042b065b00398cd59845dcb4d">get_logger</a>();</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span>  }</div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span> </div>
<div class="line"><a id="l00125" name="l00125"></a><span class="lineno">  125</span>  <span class="comment">// Use standard beautified formatting for chrono durations/etc. output (and conversely input).</span></div>
<div class="line"><a id="l00126" name="l00126"></a><span class="lineno">  126</span>  <a class="code hl_function" href="namespaceflow_1_1log.html#aaaaa1dcbf7c8dc99aceb2b6c217187fc">beautify_chrono_logger_this_thread</a>(logger_ptr);</div>
<div class="line"><a id="l00127" name="l00127"></a><span class="lineno">  127</span> </div>
<div class="line"><a id="l00128" name="l00128"></a><span class="lineno">  128</span>  <span class="keywordflow">if</span> (!thread_type.empty())</div>
<div class="line"><a id="l00129" name="l00129"></a><span class="lineno">  129</span>  {</div>
<div class="line"><a id="l00130" name="l00130"></a><span class="lineno">  130</span>    <span class="comment">// Nickname the thread for more convenient logging.</span></div>
<div class="line"><a id="l00131" name="l00131"></a><span class="lineno">  131</span>    <span class="keywordtype">string</span> thread_nickname; <span class="comment">// Write directly into this string.</span></div>
<div class="line"><a id="l00132" name="l00132"></a><span class="lineno">  132</span>    <a class="code hl_function" href="namespaceflow_1_1util.html#a8afd30c50bcd670d45442df49d1da484">util::ostream_op_to_string</a>(&amp;thread_nickname, <span class="stringliteral">&quot;nod@&quot;</span>, hex, <span class="keyword">this</span>, <span class="charliteral">&#39;_&#39;</span>, thread_type);</div>
<div class="line"><a id="l00133" name="l00133"></a><span class="lineno">  133</span>    Logger::this_thread_set_logged_nickname(thread_nickname, logger_ptr);</div>
<div class="line"><a id="l00134" name="l00134"></a><span class="lineno">  134</span>  }</div>
<div class="line"><a id="l00135" name="l00135"></a><span class="lineno">  135</span> </div>
<div class="line"><a id="l00136" name="l00136"></a><span class="lineno">  136</span>  <span class="keywordflow">return</span> logger_ptr;</div>
<div class="line"><a id="l00137" name="l00137"></a><span class="lineno">  137</span>}</div>
<div class="line"><a id="l00138" name="l00138"></a><span class="lineno">  138</span> </div>
<div class="line"><a id="l00139" name="l00139"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a16c53c4848ea976b075a0b56f33eb118">  139</a></span><a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a16c53c4848ea976b075a0b56f33eb118">Node::~Node</a>() <span class="comment">// Virtual.</span></div>
<div class="line"><a id="l00140" name="l00140"></a><span class="lineno">  140</span>{</div>
<div class="line"><a id="l00141" name="l00141"></a><span class="lineno">  141</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Waiting for Flow worker thread [T&quot;</span> &lt;&lt; <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">m_worker</a>.get_id() &lt;&lt; <span class="stringliteral">&quot;] to finish.&quot;</span>);</div>
<div class="line"><a id="l00142" name="l00142"></a><span class="lineno">  142</span> </div>
<div class="line"><a id="l00143" name="l00143"></a><span class="lineno">  143</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.stop(); <span class="comment">// Let current running callbacks finish, then exit m_task_engine.run() and the thread.</span></div>
<div class="line"><a id="l00144" name="l00144"></a><span class="lineno">  144</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">m_worker</a>.join(); <span class="comment">// Wait for thread to finish.  Closing activities are in worker_run() after run() exits.</span></div>
<div class="line"><a id="l00145" name="l00145"></a><span class="lineno">  145</span> </div>
<div class="line"><a id="l00146" name="l00146"></a><span class="lineno">  146</span>  <span class="comment">// Aside: m_net_env_sim (unless null anyway) will probably die due to ref-count=0 at the end of this { block }.</span></div>
<div class="line"><a id="l00147" name="l00147"></a><span class="lineno">  147</span> </div>
<div class="line"><a id="l00148" name="l00148"></a><span class="lineno">  148</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Node [&quot;</span> &lt;&lt; <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span>*<span class="keyword">&gt;</span>(<span class="keyword">this</span>) &lt;&lt; <span class="stringliteral">&quot;] shut down.&quot;</span>);</div>
<div class="line"><a id="l00149" name="l00149"></a><span class="lineno">  149</span>} <span class="comment">// Node::~Node()</span></div>
<div class="line"><a id="l00150" name="l00150"></a><span class="lineno">  150</span> </div>
<div class="line"><a id="l00151" name="l00151"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a5b056ed753b832458f44f537acfe86d7">  151</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a5b056ed753b832458f44f537acfe86d7">Node::worker_run</a>(<span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">util::Udp_endpoint</a> low_lvl_endpoint)</div>
<div class="line"><a id="l00152" name="l00152"></a><span class="lineno">  152</span>{</div>
<div class="line"><a id="l00153" name="l00153"></a><span class="lineno">  153</span>  <span class="keyword">using </span><a class="code hl_class" href="classflow_1_1log_1_1Logger.html">log::Logger</a>;</div>
<div class="line"><a id="l00154" name="l00154"></a><span class="lineno">  154</span>  <span class="keyword">using </span><a class="code hl_function" href="namespaceflow_1_1util.html#a74d4a66fb00055be4e1bd6ee98e04667">util::schedule_task_from_now</a>;</div>
<div class="line"><a id="l00155" name="l00155"></a><span class="lineno">  155</span>  <span class="keyword">using </span><a class="code hl_class" href="classboost_1_1system_1_1system__error.html">boost::system::system_error</a>;</div>
<div class="line"><a id="l00156" name="l00156"></a><span class="lineno">  156</span>  <span class="keyword">using </span>boost::asio::socket_base;</div>
<div class="line"><a id="l00157" name="l00157"></a><span class="lineno">  157</span>  <span class="keyword">using </span>boost::asio::post;</div>
<div class="line"><a id="l00158" name="l00158"></a><span class="lineno">  158</span>  <span class="keyword">using </span>std::string;</div>
<div class="line"><a id="l00159" name="l00159"></a><span class="lineno">  159</span>  <span class="keyword">using </span>std::hex;</div>
<div class="line"><a id="l00160" name="l00160"></a><span class="lineno">  160</span> </div>
<div class="line"><a id="l00161" name="l00161"></a><span class="lineno">  161</span>  <span class="comment">// We&#39;re in thread W.</span></div>
<div class="line"><a id="l00162" name="l00162"></a><span class="lineno">  162</span> </div>
<div class="line"><a id="l00163" name="l00163"></a><span class="lineno">  163</span>  <span class="comment">// Global (for this thread, for this Node) logging setup.</span></div>
<div class="line"><a id="l00164" name="l00164"></a><span class="lineno">  164</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aa894fd58b246c2a8d6c7c7d25a8748cb">this_thread_init_logger_setup</a>(<span class="stringliteral">&quot;wrk&quot;</span>);</div>
<div class="line"><a id="l00165" name="l00165"></a><span class="lineno">  165</span> </div>
<div class="line"><a id="l00166" name="l00166"></a><span class="lineno">  166</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Flow worker thread reporting for duty.  Will bind to [UDP &quot;</span> &lt;&lt; low_lvl_endpoint &lt;&lt; <span class="stringliteral">&quot;].&quot;</span>);</div>
<div class="line"><a id="l00167" name="l00167"></a><span class="lineno">  167</span> </div>
<div class="line"><a id="l00168" name="l00168"></a><span class="lineno">  168</span>  <span class="comment">// Set up the UDP socket at the given interface and UDP port.</span></div>
<div class="line"><a id="l00169" name="l00169"></a><span class="lineno">  169</span>  <span class="keywordflow">try</span> <span class="comment">// Performance not a concern during initialization; use exceptions for convenience.</span></div>
<div class="line"><a id="l00170" name="l00170"></a><span class="lineno">  170</span>  {</div>
<div class="line"><a id="l00171" name="l00171"></a><span class="lineno">  171</span>    <span class="comment">// BSD socket equivalents: socket(), setsockopt(), setsockopt/ioctl/whatever(), bind(); in that order.</span></div>
<div class="line"><a id="l00172" name="l00172"></a><span class="lineno">  172</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.open(low_lvl_endpoint.protocol()); <span class="comment">// Pick IPv4 vs. IPv6 based on the bind IP they provided.</span></div>
<div class="line"><a id="l00173" name="l00173"></a><span class="lineno">  173</span> </div>
<div class="line"><a id="l00174" name="l00174"></a><span class="lineno">  174</span>    <span class="comment">/* A small UDP buffer size (empirically seen to be ~80 1k datagrams in an older Linux system, for example) can</span></div>
<div class="line"><a id="l00175" name="l00175"></a><span class="lineno">  175</span><span class="comment">     * cause loss when data are coming in very fast, and thread W&#39;s processing can&#39;t keep, causing</span></div>
<div class="line"><a id="l00176" name="l00176"></a><span class="lineno">  176</span><span class="comment">     * UDP buffer overflow and thus dropped datagrams.  So we set it to a high value to avoid that</span></div>
<div class="line"><a id="l00177" name="l00177"></a><span class="lineno">  177</span><span class="comment">     * as much as we can.  Also see related @todo in Node doc header (it has to do with moving</span></div>
<div class="line"><a id="l00178" name="l00178"></a><span class="lineno">  178</span><span class="comment">     * UDP processing into a separate thread, so that datagrams are read off UDP as fast as</span></div>
<div class="line"><a id="l00179" name="l00179"></a><span class="lineno">  179</span><span class="comment">     * possible and not blocked by other processing). */</span></div>
<div class="line"><a id="l00180" name="l00180"></a><span class="lineno">  180</span> </div>
<div class="line"><a id="l00181" name="l00181"></a><span class="lineno">  181</span>    socket_base::receive_buffer_size rcv_buf_opt(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a43c42121d48a55a43a48e3a84bd10595">opt</a>(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a>.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#a78baaf1a911c8d490a13278422307e8a">m_st_low_lvl_max_buf_size</a>));</div>
<div class="line"><a id="l00182" name="l00182"></a><span class="lineno">  182</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.set_option(rcv_buf_opt);</div>
<div class="line"><a id="l00183" name="l00183"></a><span class="lineno">  183</span> </div>
<div class="line"><a id="l00184" name="l00184"></a><span class="lineno">  184</span>    <span class="comment">// Now read it back and store it for informational purposes.  OS may not respect what we tried to set.</span></div>
<div class="line"><a id="l00185" name="l00185"></a><span class="lineno">  185</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.get_option(rcv_buf_opt);</div>
<div class="line"><a id="l00186" name="l00186"></a><span class="lineno">  186</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a266ec5d00a44bc48caf37444eb2b43a1">m_low_lvl_max_buf_size</a> = rcv_buf_opt.value();</div>
<div class="line"><a id="l00187" name="l00187"></a><span class="lineno">  187</span> </div>
<div class="line"><a id="l00188" name="l00188"></a><span class="lineno">  188</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.non_blocking(<span class="keyword">true</span>);</div>
<div class="line"><a id="l00189" name="l00189"></a><span class="lineno">  189</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.bind(low_lvl_endpoint);</div>
<div class="line"><a id="l00190" name="l00190"></a><span class="lineno">  190</span> </div>
<div class="line"><a id="l00191" name="l00191"></a><span class="lineno">  191</span>    <span class="comment">/* Save it for local_low_lvl_endpoint() (for user access).  Why not just have</span></div>
<div class="line"><a id="l00192" name="l00192"></a><span class="lineno">  192</span><span class="comment">     * local_low_lvl_endpoint() call m_low_lvl_sock.local_endpoint()?  Answer: we&#39;d have to</span></div>
<div class="line"><a id="l00193" name="l00193"></a><span class="lineno">  193</span><span class="comment">     * protect m_low_lvl_sock with a mutex.  Why not save to m_low_lvl_local_endpoint directly from</span></div>
<div class="line"><a id="l00194" name="l00194"></a><span class="lineno">  194</span><span class="comment">     * low_lvl_endpoint?  Because if, say, user selected UDP port 0, we want</span></div>
<div class="line"><a id="l00195" name="l00195"></a><span class="lineno">  195</span><span class="comment">     * local_low_lvl_endpoint() to return the actual port the OS chose, not the</span></div>
<div class="line"><a id="l00196" name="l00196"></a><span class="lineno">  196</span><span class="comment">     * more-useless &quot;0.&quot; */</span></div>
<div class="line"><a id="l00197" name="l00197"></a><span class="lineno">  197</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aee89be07daf7d024921381a4bafe1289">m_low_lvl_endpoint</a> = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.local_endpoint();</div>
<div class="line"><a id="l00198" name="l00198"></a><span class="lineno">  198</span>  }</div>
<div class="line"><a id="l00199" name="l00199"></a><span class="lineno">  199</span>  <span class="keywordflow">catch</span> (<span class="keyword">const</span> system_error&amp; exc)</div>
<div class="line"><a id="l00200" name="l00200"></a><span class="lineno">  200</span>  {</div>
<div class="line"><a id="l00201" name="l00201"></a><span class="lineno">  201</span>    <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> sys_err_code = exc.code();</div>
<div class="line"><a id="l00202" name="l00202"></a><span class="lineno">  202</span>    <a class="code hl_define" href="error_2error_8hpp.html#a019ee6e90802e444572dd78d312d6e23">FLOW_ERROR_SYS_ERROR_LOG_WARNING</a>();</div>
<div class="line"><a id="l00203" name="l00203"></a><span class="lineno">  203</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Unable to set up low-level socket.  Node cannot initialize.  Thread exiting.&quot;</span>);</div>
<div class="line"><a id="l00204" name="l00204"></a><span class="lineno">  204</span> </div>
<div class="line"><a id="l00205" name="l00205"></a><span class="lineno">  205</span>    <span class="comment">// Constructor is waiting to see if we were able to start event loop.  We were not.</span></div>
<div class="line"><a id="l00206" name="l00206"></a><span class="lineno">  206</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.stop(); <span class="comment">// So that Node::running() will return false.</span></div>
<div class="line"><a id="l00207" name="l00207"></a><span class="lineno">  207</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aa440f6ff5442c58323bec7a2304b0d90">m_event_loop_ready</a>.set_value(exc.code());</div>
<div class="line"><a id="l00208" name="l00208"></a><span class="lineno">  208</span> </div>
<div class="line"><a id="l00209" name="l00209"></a><span class="lineno">  209</span>    <span class="comment">// Since we never started m_task_engine, Node::running() will return false.</span></div>
<div class="line"><a id="l00210" name="l00210"></a><span class="lineno">  210</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00211" name="l00211"></a><span class="lineno">  211</span>  }</div>
<div class="line"><a id="l00212" name="l00212"></a><span class="lineno">  212</span> </div>
<div class="line"><a id="l00213" name="l00213"></a><span class="lineno">  213</span>  <span class="comment">// Once run() executes below, this should be the first thing it does (report to constructor thread).</span></div>
<div class="line"><a id="l00214" name="l00214"></a><span class="lineno">  214</span>  post(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>, [<span class="keyword">this</span>]()</div>
<div class="line"><a id="l00215" name="l00215"></a><span class="lineno">  215</span>  {</div>
<div class="line"><a id="l00216" name="l00216"></a><span class="lineno">  216</span>    <span class="comment">// We are in thread W.</span></div>
<div class="line"><a id="l00217" name="l00217"></a><span class="lineno">  217</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aa440f6ff5442c58323bec7a2304b0d90">m_event_loop_ready</a>.set_value(<a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>());</div>
<div class="line"><a id="l00218" name="l00218"></a><span class="lineno">  218</span>  });</div>
<div class="line"><a id="l00219" name="l00219"></a><span class="lineno">  219</span> </div>
<div class="line"><a id="l00220" name="l00220"></a><span class="lineno">  220</span>  <span class="comment">// When a packet is available for reading (or error), call this-&gt;low_lvl_recv_and_handle(&lt;error code&gt;).</span></div>
<div class="line"><a id="l00221" name="l00221"></a><span class="lineno">  221</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ade12d2ebbd88b62432089a3a071b9514">async_low_lvl_recv</a>();</div>
<div class="line"><a id="l00222" name="l00222"></a><span class="lineno">  222</span> </div>
<div class="line"><a id="l00223" name="l00223"></a><span class="lineno">  223</span>  <span class="comment">// Also execute some low-priority tasks (such as periodic stat logging) every S_REGULAR_INFREQUENT_TASKS_PERIOD.</span></div>
<div class="line"><a id="l00224" name="l00224"></a><span class="lineno">  224</span>  <a class="code hl_function" href="namespaceflow_1_1util.html#a74d4a66fb00055be4e1bd6ee98e04667">schedule_task_from_now</a>(<a class="code hl_function" href="classflow_1_1log_1_1Log__context.html#af4db395042b065b00398cd59845dcb4d">get_logger</a>(), <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a2f97b363281b79ef4f399789442c84de">S_REGULAR_INFREQUENT_TASKS_PERIOD</a>, <span class="keyword">true</span>, &amp;<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>,</div>
<div class="line"><a id="l00225" name="l00225"></a><span class="lineno">  225</span>                         [<span class="keyword">this</span>](<span class="keywordtype">bool</span>)</div>
<div class="line"><a id="l00226" name="l00226"></a><span class="lineno">  226</span>  {</div>
<div class="line"><a id="l00227" name="l00227"></a><span class="lineno">  227</span>    <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb">perform_regular_infrequent_tasks</a>(<span class="keyword">true</span>);</div>
<div class="line"><a id="l00228" name="l00228"></a><span class="lineno">  228</span>  });</div>
<div class="line"><a id="l00229" name="l00229"></a><span class="lineno">  229</span> </div>
<div class="line"><a id="l00230" name="l00230"></a><span class="lineno">  230</span>  <span class="comment">/* Go!  Sleep until the next registered event.  Our handlers (like low_lvl_recv_and_handle()) should themselves</span></div>
<div class="line"><a id="l00231" name="l00231"></a><span class="lineno">  231</span><span class="comment">   * register more events to wait for thus ensuring run() doesn&#39;t run out of work (thus doesn&#39;t exit) until</span></div>
<div class="line"><a id="l00232" name="l00232"></a><span class="lineno">  232</span><span class="comment">   * something intentionally wants to stop it (stop the Node). */</span></div>
<div class="line"><a id="l00233" name="l00233"></a><span class="lineno">  233</span> </div>
<div class="line"><a id="l00234" name="l00234"></a><span class="lineno">  234</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Low-level socket initialized.&quot;</span>);</div>
<div class="line"><a id="l00235" name="l00235"></a><span class="lineno">  235</span> </div>
<div class="line"><a id="l00236" name="l00236"></a><span class="lineno">  236</span>  <span class="keywordflow">if</span> (<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a>.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#aea7861f3c7739f8e588293d16a2de447">m_st_capture_interrupt_signals_internally</a>)</div>
<div class="line"><a id="l00237" name="l00237"></a><span class="lineno">  237</span>  {</div>
<div class="line"><a id="l00238" name="l00238"></a><span class="lineno">  238</span>    <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Setting up internal wait-interrupting interrupt signal handler.  &quot;</span></div>
<div class="line"><a id="l00239" name="l00239"></a><span class="lineno">  239</span>                  <span class="stringliteral">&quot;CAUTION!  User program MUST avoid using non-boost::asio::signal_set signal handling!  &quot;</span></div>
<div class="line"><a id="l00240" name="l00240"></a><span class="lineno">  240</span>                  <span class="stringliteral">&quot;If it does use non-boost.asio, behavior is undefined.&quot;</span>);</div>
<div class="line"><a id="l00241" name="l00241"></a><span class="lineno">  241</span> </div>
<div class="line"><a id="l00242" name="l00242"></a><span class="lineno">  242</span>    <span class="comment">// Add the classic EINTR-inducing signal numbers.</span></div>
<div class="line"><a id="l00243" name="l00243"></a><span class="lineno">  243</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#abecf0f8111af82fa081c71fda490608a">m_signal_set</a>.add(SIGINT);</div>
<div class="line"><a id="l00244" name="l00244"></a><span class="lineno">  244</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#abecf0f8111af82fa081c71fda490608a">m_signal_set</a>.add(SIGTERM);</div>
<div class="line"><a id="l00245" name="l00245"></a><span class="lineno">  245</span> </div>
<div class="line"><a id="l00246" name="l00246"></a><span class="lineno">  246</span>    <span class="comment">/* At this point, receiving those signals will NOT just exit the program (or whatever other non-boost.asio</span></div>
<div class="line"><a id="l00247" name="l00247"></a><span class="lineno">  247</span><span class="comment">     * handling was active before the .add() calls).  Before actually reporting successful initialization (reminder:</span></div>
<div class="line"><a id="l00248" name="l00248"></a><span class="lineno">  248</span><span class="comment">     * constructor is currently waiting for us to finish initializatio and report it via the promise object), set up</span></div>
<div class="line"><a id="l00249" name="l00249"></a><span class="lineno">  249</span><span class="comment">     * the handler that&#39;ll be called upon receiving the signals. */</span></div>
<div class="line"><a id="l00250" name="l00250"></a><span class="lineno">  250</span> </div>
<div class="line"><a id="l00251" name="l00251"></a><span class="lineno">  251</span>    <span class="comment">/* this-&gt;interrupt_all_waits_internal_sig_handler(err_code, signal_number) will be called on signal (or error).</span></div>
<div class="line"><a id="l00252" name="l00252"></a><span class="lineno">  252</span><span class="comment">     * Note that that function&#39;s contract (from its doc comment) is it must execute in thread W.</span></div>
<div class="line"><a id="l00253" name="l00253"></a><span class="lineno">  253</span><span class="comment">     * Indeed boost::asio::io_context semantics guarantee it&#39;ll run in thread W (not some</span></div>
<div class="line"><a id="l00254" name="l00254"></a><span class="lineno">  254</span><span class="comment">     * no-man&#39;s-land signal handler thread of execution, as one might fear could be the case) for the same reason</span></div>
<div class="line"><a id="l00255" name="l00255"></a><span class="lineno">  255</span><span class="comment">     * the various socket I/O handlers and timer handlers above will run in thread W: because we&#39;ll run</span></div>
<div class="line"><a id="l00256" name="l00256"></a><span class="lineno">  256</span><span class="comment">     * m_task_engine.run() below from thread W, and all such functions are guaranteed to run &quot;as if&quot;</span></div>
<div class="line"><a id="l00257" name="l00257"></a><span class="lineno">  257</span><span class="comment">     * post(m_task_engine)ed.  Anything post(m_task_engine)ed is guaranteed by boost.asio docs to execute form</span></div>
<div class="line"><a id="l00258" name="l00258"></a><span class="lineno">  258</span><span class="comment">     * the same thread as m_task_engine.run(). */</span></div>
<div class="line"><a id="l00259" name="l00259"></a><span class="lineno">  259</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#abecf0f8111af82fa081c71fda490608a">m_signal_set</a>.async_wait([<span class="keyword">this</span>](<span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>&amp; sys_err_code, <span class="keywordtype">int</span> sig_num)</div>
<div class="line"><a id="l00260" name="l00260"></a><span class="lineno">  260</span>    {</div>
<div class="line"><a id="l00261" name="l00261"></a><span class="lineno">  261</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ae996cab95eb139d00f0d430093e64a5f">interrupt_all_waits_internal_sig_handler</a>(sys_err_code, sig_num);</div>
<div class="line"><a id="l00262" name="l00262"></a><span class="lineno">  262</span>    });</div>
<div class="line"><a id="l00263" name="l00263"></a><span class="lineno">  263</span>  } <span class="comment">// if (m_opts.m_st_capture_interrupt_signals_internally)</span></div>
<div class="line"><a id="l00264" name="l00264"></a><span class="lineno">  264</span>  <span class="comment">/* else if (!m_opts.m_st_capture_interrupt_signals_internally)</span></div>
<div class="line"><a id="l00265" name="l00265"></a><span class="lineno">  265</span><span class="comment">   * {</span></div>
<div class="line"><a id="l00266" name="l00266"></a><span class="lineno">  266</span><span class="comment">   *   Do NOT .add() anything; and don&#39;t async_wait() anything.  As noted in comment at m_signal_set construction time,</span></div>
<div class="line"><a id="l00267" name="l00267"></a><span class="lineno">  267</span><span class="comment">   *   .add() does more than make it possible to .async_wait().  It also replaces any default OS or user&#39;s own</span></div>
<div class="line"><a id="l00268" name="l00268"></a><span class="lineno">  268</span><span class="comment">   *   non-boost.asio signal handling machinery with boost.asio&#39;s signal_set machinery. That can be quite draconian,</span></div>
<div class="line"><a id="l00269" name="l00269"></a><span class="lineno">  269</span><span class="comment">   *   so user must specifically set that option to true.  If it&#39;s false (in all Nodes constructed by user in the entire</span></div>
<div class="line"><a id="l00270" name="l00270"></a><span class="lineno">  270</span><span class="comment">   *   app), then whatever signal handling machinery the user wants to set up for themselves (or leave at OS&#39;s</span></div>
<div class="line"><a id="l00271" name="l00271"></a><span class="lineno">  271</span><span class="comment">   *   discretion) will remain undisturbed.  By the way, of course, they can use boost.asio machinery themselves too;</span></div>
<div class="line"><a id="l00272" name="l00272"></a><span class="lineno">  272</span><span class="comment">   *   it&#39;s just that doing so would still work even if m_st_capture_interrupt_signals_internally were true, so that&#39;s</span></div>
<div class="line"><a id="l00273" name="l00273"></a><span class="lineno">  273</span><span class="comment">   *   not the dangerous scenario.</span></div>
<div class="line"><a id="l00274" name="l00274"></a><span class="lineno">  274</span><span class="comment">   * } */</span></div>
<div class="line"><a id="l00275" name="l00275"></a><span class="lineno">  275</span> </div>
<div class="line"><a id="l00276" name="l00276"></a><span class="lineno">  276</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Flow event loop starting now.&quot;</span>);</div>
<div class="line"><a id="l00277" name="l00277"></a><span class="lineno">  277</span> </div>
<div class="line"><a id="l00278" name="l00278"></a><span class="lineno">  278</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.run();</div>
<div class="line"><a id="l00279" name="l00279"></a><span class="lineno">  279</span> </div>
<div class="line"><a id="l00280" name="l00280"></a><span class="lineno">  280</span>  <span class="comment">/* Destructor must have stop()ped m_task_engine.  restart() will allow the below poll()s to</span></div>
<div class="line"><a id="l00281" name="l00281"></a><span class="lineno">  281</span><span class="comment">   * proceed. */</span></div>
<div class="line"><a id="l00282" name="l00282"></a><span class="lineno">  282</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.restart();</div>
<div class="line"><a id="l00283" name="l00283"></a><span class="lineno">  283</span> </div>
<div class="line"><a id="l00284" name="l00284"></a><span class="lineno">  284</span>  <span class="comment">// Log final state report before closing down.  Do not schedule to run again.</span></div>
<div class="line"><a id="l00285" name="l00285"></a><span class="lineno">  285</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb">perform_regular_infrequent_tasks</a>(<span class="keyword">false</span>);</div>
<div class="line"><a id="l00286" name="l00286"></a><span class="lineno">  286</span> </div>
<div class="line"><a id="l00287" name="l00287"></a><span class="lineno">  287</span>  <span class="comment">/* We should clean up everything (like close sockets, ensuring user gets errors when trying to</span></div>
<div class="line"><a id="l00288" name="l00288"></a><span class="lineno">  288</span><span class="comment">   * send/receive/etc.), but quickly.  We should avoid potentially slow blocking operations like</span></div>
<div class="line"><a id="l00289" name="l00289"></a><span class="lineno">  289</span><span class="comment">   * graceful closes here; if the Node is shutting down, shut it down abruptly.  @todo Reconsider.</span></div>
<div class="line"><a id="l00290" name="l00290"></a><span class="lineno">  290</span><span class="comment">   *</span></div>
<div class="line"><a id="l00291" name="l00291"></a><span class="lineno">  291</span><span class="comment">   * Therefore sending RSTs synchronously to all connected peers and then abruptly closing all</span></div>
<div class="line"><a id="l00292" name="l00292"></a><span class="lineno">  292</span><span class="comment">   * sockets should be sufficient.  User threads waiting on Readable, Writable, Acceptable will be</span></div>
<div class="line"><a id="l00293" name="l00293"></a><span class="lineno">  293</span><span class="comment">   * woken and informed of the error. */</span></div>
<div class="line"><a id="l00294" name="l00294"></a><span class="lineno">  294</span> </div>
<div class="line"><a id="l00295" name="l00295"></a><span class="lineno">  295</span>  <span class="keywordflow">try</span> <span class="comment">// Performance not a concern during shutdown; use exceptions for convenience.</span></div>
<div class="line"><a id="l00296" name="l00296"></a><span class="lineno">  296</span>  {</div>
<div class="line"><a id="l00297" name="l00297"></a><span class="lineno">  297</span>    <span class="comment">/* stop() lets any handlers running at the time finish but then run() exits before running any</span></div>
<div class="line"><a id="l00298" name="l00298"></a><span class="lineno">  298</span><span class="comment">     * more handlers.  This means there may have been some handlers queued up to run immediately.</span></div>
<div class="line"><a id="l00299" name="l00299"></a><span class="lineno">  299</span><span class="comment">     * Let them run now, as if stop() was called just a few moments later. */</span></div>
<div class="line"><a id="l00300" name="l00300"></a><span class="lineno">  300</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Flow worker thread event loop stopped.  Running queued up handlers.&quot;</span>);</div>
<div class="line"><a id="l00301" name="l00301"></a><span class="lineno">  301</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.poll();</div>
<div class="line"><a id="l00302" name="l00302"></a><span class="lineno">  302</span> </div>
<div class="line"><a id="l00303" name="l00303"></a><span class="lineno">  303</span>    <span class="comment">// Send RSTs (synchronously).</span></div>
<div class="line"><a id="l00304" name="l00304"></a><span class="lineno">  304</span> </div>
<div class="line"><a id="l00305" name="l00305"></a><span class="lineno">  305</span>    <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;Worker thread told to stop (probably Node destructor executed).  &quot;</span></div>
<div class="line"><a id="l00306" name="l00306"></a><span class="lineno">  306</span>                    <span class="stringliteral">&quot;Sending [RST] to all open Flow sockets.&quot;</span>);</div>
<div class="line"><a id="l00307" name="l00307"></a><span class="lineno">  307</span> </div>
<div class="line"><a id="l00308" name="l00308"></a><span class="lineno">  308</span>    <span class="comment">// Just in case the RST sending operation blocks for some reason....</span></div>
<div class="line"><a id="l00309" name="l00309"></a><span class="lineno">  309</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.non_blocking(<span class="keyword">false</span>);</div>
<div class="line"><a id="l00310" name="l00310"></a><span class="lineno">  310</span>    <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; sock_pair : <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>)</div>
<div class="line"><a id="l00311" name="l00311"></a><span class="lineno">  311</span>    {</div>
<div class="line"><a id="l00312" name="l00312"></a><span class="lineno">  312</span>      <span class="comment">// May technically block but should not be for long if so (UDP).  Probably OK.</span></div>
<div class="line"><a id="l00313" name="l00313"></a><span class="lineno">  313</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a287eae1113865dba06c103cf023404ae">sync_sock_low_lvl_rst_send</a>(sock_pair.second); <span class="comment">// Will log if there&#39;s a problem.</span></div>
<div class="line"><a id="l00314" name="l00314"></a><span class="lineno">  314</span>    }</div>
<div class="line"><a id="l00315" name="l00315"></a><span class="lineno">  315</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.non_blocking(<span class="keyword">true</span>);</div>
<div class="line"><a id="l00316" name="l00316"></a><span class="lineno">  316</span> </div>
<div class="line"><a id="l00317" name="l00317"></a><span class="lineno">  317</span>    <span class="comment">// Now close (synchronously) all open sockets.  This posts no handlers on m_task_engine except canceled timers.</span></div>
<div class="line"><a id="l00318" name="l00318"></a><span class="lineno">  318</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Abruptly closing all Flow peer sockets.&quot;</span>);</div>
<div class="line"><a id="l00319" name="l00319"></a><span class="lineno">  319</span>    <span class="keywordflow">while</span> (!<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>.empty()) <span class="comment">// Don&#39;t loop over it -- loop body will erase elements!</span></div>
<div class="line"><a id="l00320" name="l00320"></a><span class="lineno">  320</span>    {</div>
<div class="line"><a id="l00321" name="l00321"></a><span class="lineno">  321</span>      Socket_id_to_socket_map::const_iterator sock_it = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>.begin();</div>
<div class="line"><a id="l00322" name="l00322"></a><span class="lineno">  322</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ade49e7bc7202a0adf33fec2d93d1b177">close_connection_immediately</a>(sock_it-&gt;first, sock_it-&gt;second, <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b">error::Code::S_NODE_SHUTTING_DOWN</a>, <span class="keyword">false</span>);</div>
<div class="line"><a id="l00323" name="l00323"></a><span class="lineno">  323</span>      <span class="comment">// ^-- defer_delta_checks == false: no need to optimize during shutdown.</span></div>
<div class="line"><a id="l00324" name="l00324"></a><span class="lineno">  324</span> </div>
<div class="line"><a id="l00325" name="l00325"></a><span class="lineno">  325</span>      <span class="comment">// Note that the above covers not-fully-open (e.g., awaiting SYN_ACK) sockets as well.</span></div>
<div class="line"><a id="l00326" name="l00326"></a><span class="lineno">  326</span>    }</div>
<div class="line"><a id="l00327" name="l00327"></a><span class="lineno">  327</span> </div>
<div class="line"><a id="l00328" name="l00328"></a><span class="lineno">  328</span>    <span class="comment">// Close (synchronously) all server sockets.</span></div>
<div class="line"><a id="l00329" name="l00329"></a><span class="lineno">  329</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Abruptly closing all Flow server sockets.&quot;</span>);</div>
<div class="line"><a id="l00330" name="l00330"></a><span class="lineno">  330</span>    <span class="keywordflow">while</span> (!<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aae28990628a86a07327f49973f2390df">m_servs</a>.empty()) <span class="comment">// As above.</span></div>
<div class="line"><a id="l00331" name="l00331"></a><span class="lineno">  331</span>    {</div>
<div class="line"><a id="l00332" name="l00332"></a><span class="lineno">  332</span>      Port_to_server_map::const_iterator serv_it = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aae28990628a86a07327f49973f2390df">m_servs</a>.begin();</div>
<div class="line"><a id="l00333" name="l00333"></a><span class="lineno">  333</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#adf6d71af81def2d030f0fef159c1b06d">close_empty_server_immediately</a>(serv_it-&gt;first, serv_it-&gt;second, <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b">error::Code::S_NODE_SHUTTING_DOWN</a>, <span class="keyword">false</span>);</div>
<div class="line"><a id="l00334" name="l00334"></a><span class="lineno">  334</span>      <span class="comment">// ^-- defer_delta_checks == false: no need to optimize during shutdown.</span></div>
<div class="line"><a id="l00335" name="l00335"></a><span class="lineno">  335</span>    }</div>
<div class="line"><a id="l00336" name="l00336"></a><span class="lineno">  336</span> </div>
<div class="line"><a id="l00337" name="l00337"></a><span class="lineno">  337</span>    <span class="comment">// Close all Event_sets.  This is always synchronous.  As advertised, this may trigger on-event behavior.</span></div>
<div class="line"><a id="l00338" name="l00338"></a><span class="lineno">  338</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Closing all event sets and waking up any on-going waits on those event sets.&quot;</span>);</div>
<div class="line"><a id="l00339" name="l00339"></a><span class="lineno">  339</span>    <span class="keywordflow">while</span> (!<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ae43345472c4f41933a9c16d114cc937b">m_event_sets</a>.empty()) <span class="comment">// As above.</span></div>
<div class="line"><a id="l00340" name="l00340"></a><span class="lineno">  340</span>    {</div>
<div class="line"><a id="l00341" name="l00341"></a><span class="lineno">  341</span>      <span class="keyword">const</span> <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Event_set::Ptr</a> event_set = *<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ae43345472c4f41933a9c16d114cc937b">m_event_sets</a>.begin();</div>
<div class="line"><a id="l00342" name="l00342"></a><span class="lineno">  342</span>      <a class="code hl_typedef" href="classflow_1_1net__flow_1_1Event__set.html#a7e6ff0e1ad4c13220a371045101a5eff">Event_set::Lock_guard</a> lock(event_set-&gt;m_mutex); <span class="comment">// Pre-condition for event_set_close_worker().</span></div>
<div class="line"><a id="l00343" name="l00343"></a><span class="lineno">  343</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a6727ca42e15c8627c1ed3d94e6dd7a53">event_set_close_worker</a>(event_set);</div>
<div class="line"><a id="l00344" name="l00344"></a><span class="lineno">  344</span>    }</div>
<div class="line"><a id="l00345" name="l00345"></a><span class="lineno">  345</span> </div>
<div class="line"><a id="l00346" name="l00346"></a><span class="lineno">  346</span>    <span class="comment">// Run those canceled timer handlers for cleanliness (and in case that would let go of some resources).</span></div>
<div class="line"><a id="l00347" name="l00347"></a><span class="lineno">  347</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Cleaning up canceled timer tasks.&quot;</span>);</div>
<div class="line"><a id="l00348" name="l00348"></a><span class="lineno">  348</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.poll();</div>
<div class="line"><a id="l00349" name="l00349"></a><span class="lineno">  349</span> </div>
<div class="line"><a id="l00350" name="l00350"></a><span class="lineno">  350</span>    <span class="comment">/* Note: to ensure everything is cleaned up by this point, turn on TRACE logging and see that</span></div>
<div class="line"><a id="l00351" name="l00351"></a><span class="lineno">  351</span><span class="comment">     * (at least the major classes&#39;) destructors for all objects have logged that they are being</span></div>
<div class="line"><a id="l00352" name="l00352"></a><span class="lineno">  352</span><span class="comment">     * destroyed.  Be especially careful with any classes that we work with via shared_ptrs</span></div>
<div class="line"><a id="l00353" name="l00353"></a><span class="lineno">  353</span><span class="comment">     * (Peer_socket and others). */</span></div>
<div class="line"><a id="l00354" name="l00354"></a><span class="lineno">  354</span> </div>
<div class="line"><a id="l00355" name="l00355"></a><span class="lineno">  355</span>    <span class="comment">// Let go of low-level net-stack resources.</span></div>
<div class="line"><a id="l00356" name="l00356"></a><span class="lineno">  356</span>    <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Closing low-level UDP socket.&quot;</span>);</div>
<div class="line"><a id="l00357" name="l00357"></a><span class="lineno">  357</span> </div>
<div class="line"><a id="l00358" name="l00358"></a><span class="lineno">  358</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.non_blocking(<span class="keyword">false</span>); <span class="comment">// Just in case closing operation blocks for some reason....</span></div>
<div class="line"><a id="l00359" name="l00359"></a><span class="lineno">  359</span>    <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">m_low_lvl_sock</a>.close(); <span class="comment">// Give socket back to OS (UDP close()).</span></div>
<div class="line"><a id="l00360" name="l00360"></a><span class="lineno">  360</span>  } <span class="comment">// try</span></div>
<div class="line"><a id="l00361" name="l00361"></a><span class="lineno">  361</span>  <span class="keywordflow">catch</span> (<span class="keyword">const</span> system_error&amp; exc)</div>
<div class="line"><a id="l00362" name="l00362"></a><span class="lineno">  362</span>  {</div>
<div class="line"><a id="l00363" name="l00363"></a><span class="lineno">  363</span>    <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> sys_err_code = exc.code();</div>
<div class="line"><a id="l00364" name="l00364"></a><span class="lineno">  364</span>    <a class="code hl_define" href="error_2error_8hpp.html#a019ee6e90802e444572dd78d312d6e23">FLOW_ERROR_SYS_ERROR_LOG_WARNING</a>();</div>
<div class="line"><a id="l00365" name="l00365"></a><span class="lineno">  365</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Could not cleanly shutdown, but still shut down.&quot;</span>);</div>
<div class="line"><a id="l00366" name="l00366"></a><span class="lineno">  366</span>  }</div>
<div class="line"><a id="l00367" name="l00367"></a><span class="lineno">  367</span>} <span class="comment">// Node::worker_run()</span></div>
<div class="line"><a id="l00368" name="l00368"></a><span class="lineno">  368</span> </div>
<div class="line"><a id="l00369" name="l00369"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a4cb3dcb90f1dfc44a4343c0e89ce6b83">  369</a></span><span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">util::Udp_endpoint</a>&amp; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4cb3dcb90f1dfc44a4343c0e89ce6b83">Node::local_low_lvl_endpoint</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00370" name="l00370"></a><span class="lineno">  370</span><span class="keyword"></span>{</div>
<div class="line"><a id="l00371" name="l00371"></a><span class="lineno">  371</span>  <span class="comment">// We are in thread U != W, but that&#39;s OK (m_low_lvl_local_endpoint cannot change after constructor).</span></div>
<div class="line"><a id="l00372" name="l00372"></a><span class="lineno">  372</span>  <span class="keywordflow">return</span> <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aee89be07daf7d024921381a4bafe1289">m_low_lvl_endpoint</a>;</div>
<div class="line"><a id="l00373" name="l00373"></a><span class="lineno">  373</span>}</div>
<div class="line"><a id="l00374" name="l00374"></a><span class="lineno">  374</span> </div>
<div class="line"><a id="l00375" name="l00375"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a0fba26db0055a969f3869014bc5c2bfc">  375</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a0fba26db0055a969f3869014bc5c2bfc">Node::perform_accumulated_on_recv_tasks</a>()</div>
<div class="line"><a id="l00376" name="l00376"></a><span class="lineno">  376</span>{</div>
<div class="line"><a id="l00377" name="l00377"></a><span class="lineno">  377</span>  <span class="comment">// We are in thread W.</span></div>
<div class="line"><a id="l00378" name="l00378"></a><span class="lineno">  378</span> </div>
<div class="line"><a id="l00379" name="l00379"></a><span class="lineno">  379</span>  <span class="comment">/* We&#39;re being executed from the end of low_lvl_recv_and_handle() or</span></div>
<div class="line"><a id="l00380" name="l00380"></a><span class="lineno">  380</span><span class="comment">   * async part of async_wait_latency_then_handle_incoming().</span></div>
<div class="line"><a id="l00381" name="l00381"></a><span class="lineno">  381</span><span class="comment">   * Thus we must perform tasks, accumulated over the course of that call for efficiency, now. */</span></div>
<div class="line"><a id="l00382" name="l00382"></a><span class="lineno">  382</span> </div>
<div class="line"><a id="l00383" name="l00383"></a><span class="lineno">  383</span>  <span class="comment">// Handle per-socket tasks.</span></div>
<div class="line"><a id="l00384" name="l00384"></a><span class="lineno">  384</span> </div>
<div class="line"><a id="l00385" name="l00385"></a><span class="lineno">  385</span>  <span class="comment">// Handle accumulated incoming acknowledgments/rcv_wnd updates.</span></div>
<div class="line"><a id="l00386" name="l00386"></a><span class="lineno">  386</span>  <span class="keywordflow">for</span> (<a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Peer_socket::Ptr</a> sock : <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a7d9f418a3c99197e58f71ce2fff2997f">m_socks_with_accumulated_acks</a>)</div>
<div class="line"><a id="l00387" name="l00387"></a><span class="lineno">  387</span>  {</div>
<div class="line"><a id="l00388" name="l00388"></a><span class="lineno">  388</span>    <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a136d9ccd25634cee2955ea79ae829006">handle_accumulated_acks</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>(sock), sock);</div>
<div class="line"><a id="l00389" name="l00389"></a><span class="lineno">  389</span>  }</div>
<div class="line"><a id="l00390" name="l00390"></a><span class="lineno">  390</span>  <span class="comment">// Clean slate for the next receive handler invocation.</span></div>
<div class="line"><a id="l00391" name="l00391"></a><span class="lineno">  391</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a7d9f418a3c99197e58f71ce2fff2997f">m_socks_with_accumulated_acks</a>.clear();</div>
<div class="line"><a id="l00392" name="l00392"></a><span class="lineno">  392</span> </div>
<div class="line"><a id="l00393" name="l00393"></a><span class="lineno">  393</span>  <span class="comment">// Handle accumulated outgoing acknowledgments.</span></div>
<div class="line"><a id="l00394" name="l00394"></a><span class="lineno">  394</span>  <span class="keywordflow">for</span> (<a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Peer_socket::Ptr</a> sock : <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a7bea132db0e45ea01b9a6bd22fd0fadb">m_socks_with_accumulated_pending_acks</a>)</div>
<div class="line"><a id="l00395" name="l00395"></a><span class="lineno">  395</span>  {</div>
<div class="line"><a id="l00396" name="l00396"></a><span class="lineno">  396</span>    <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a45583714bc147300158f074ecacce0fd">handle_accumulated_pending_acks</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>(sock), sock);</div>
<div class="line"><a id="l00397" name="l00397"></a><span class="lineno">  397</span>  }</div>
<div class="line"><a id="l00398" name="l00398"></a><span class="lineno">  398</span>  <span class="comment">// Clean slate for the next receive handler invocation.</span></div>
<div class="line"><a id="l00399" name="l00399"></a><span class="lineno">  399</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a7bea132db0e45ea01b9a6bd22fd0fadb">m_socks_with_accumulated_pending_acks</a>.clear();</div>
<div class="line"><a id="l00400" name="l00400"></a><span class="lineno">  400</span> </div>
<div class="line"><a id="l00401" name="l00401"></a><span class="lineno">  401</span>  <span class="comment">/* Have read all available low-level data.  As a result m_sock_events may have elements (various</span></div>
<div class="line"><a id="l00402" name="l00402"></a><span class="lineno">  402</span><span class="comment">   * events that have occurred, like a socket becoming Readable).  Therefore a &quot;delta&quot; check of</span></div>
<div class="line"><a id="l00403" name="l00403"></a><span class="lineno">  403</span><span class="comment">   * all Event_sets is needed, so that the user is informed of any events that he&#39;s been waiting</span></div>
<div class="line"><a id="l00404" name="l00404"></a><span class="lineno">  404</span><span class="comment">   * on that have occurred.  (See Event_set::async_wait() for details and general strategy.)</span></div>
<div class="line"><a id="l00405" name="l00405"></a><span class="lineno">  405</span><span class="comment">   *</span></div>
<div class="line"><a id="l00406" name="l00406"></a><span class="lineno">  406</span><span class="comment">   * Pass &quot;false&quot; to event_set_check_delta(), meaning &quot;you must in fact check the Event_sets</span></div>
<div class="line"><a id="l00407" name="l00407"></a><span class="lineno">  407</span><span class="comment">   * instead of deferring until later.&quot;  Could we defer here?  Not really.  If events have</span></div>
<div class="line"><a id="l00408" name="l00408"></a><span class="lineno">  408</span><span class="comment">   * occurred, we have a &quot;non-blocking&quot; amount of time since then during which we must inform the</span></div>
<div class="line"><a id="l00409" name="l00409"></a><span class="lineno">  409</span><span class="comment">   * user of the events that have occurred.  Doing so within one receive loop of detecting the</span></div>
<div class="line"><a id="l00410" name="l00410"></a><span class="lineno">  410</span><span class="comment">   * events meets this criterion (since boost.asio is not given a chance to sleep -- we haven&#39;t</span></div>
<div class="line"><a id="l00411" name="l00411"></a><span class="lineno">  411</span><span class="comment">   * exited the handler).  If we do exit the handler, boost.asio can sleep (until the next timer</span></div>
<div class="line"><a id="l00412" name="l00412"></a><span class="lineno">  412</span><span class="comment">   * or more UDP data arrive, for example), which certainly breaks the criterion.  So we must do</span></div>
<div class="line"><a id="l00413" name="l00413"></a><span class="lineno">  413</span><span class="comment">   * it no later than now.</span></div>
<div class="line"><a id="l00414" name="l00414"></a><span class="lineno">  414</span><span class="comment">   *</span></div>
<div class="line"><a id="l00415" name="l00415"></a><span class="lineno">  415</span><span class="comment">   * Do this AFTER the above, because handle_accumulated_*() may have added more events to handle</span></div>
<div class="line"><a id="l00416" name="l00416"></a><span class="lineno">  416</span><span class="comment">   * here (but event_set_all_check_delta() cannot add more tasks for the former to perform). */</span></div>
<div class="line"><a id="l00417" name="l00417"></a><span class="lineno">  417</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a8a4ddf81ddbeab1f740940c4cc0d3625">event_set_all_check_delta</a>(<span class="keyword">false</span>);</div>
<div class="line"><a id="l00418" name="l00418"></a><span class="lineno">  418</span>} <span class="comment">// Node::perform_accumulated_on_recv_tasks()</span></div>
<div class="line"><a id="l00419" name="l00419"></a><span class="lineno">  419</span> </div>
<div class="line"><a id="l00420" name="l00420"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#aae148cec361b59237996a4b30c6624b5">  420</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aae148cec361b59237996a4b30c6624b5">Node::running</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l00421" name="l00421"></a><span class="lineno">  421</span><span class="keyword"></span>{</div>
<div class="line"><a id="l00422" name="l00422"></a><span class="lineno">  422</span>  <span class="comment">// Simply check if the event loop is waiting for events vs. ran out of work (failed).</span></div>
<div class="line"><a id="l00423" name="l00423"></a><span class="lineno">  423</span>  <span class="keywordflow">return</span> !<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>.stopped();</div>
<div class="line"><a id="l00424" name="l00424"></a><span class="lineno">  424</span>}</div>
<div class="line"><a id="l00425" name="l00425"></a><span class="lineno">  425</span> </div>
<div class="line"><a id="l00426" name="l00426"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a1699dfdaf3e5ebe1b1d715a9c306d116">  426</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a1699dfdaf3e5ebe1b1d715a9c306d116">Node::handle_incoming</a>(<a class="code hl_typedef" href="namespaceflow_1_1util.html#af09888b3a8feaff209b6625e493bc338">util::Blob</a>* packet_data,</div>
<div class="line"><a id="l00427" name="l00427"></a><span class="lineno">  427</span>                           <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">util::Udp_endpoint</a>&amp; low_lvl_remote_endpoint)</div>
<div class="line"><a id="l00428" name="l00428"></a><span class="lineno">  428</span>{</div>
<div class="line"><a id="l00429" name="l00429"></a><span class="lineno">  429</span>  <span class="keyword">using </span>boost::static_pointer_cast;</div>
<div class="line"><a id="l00430" name="l00430"></a><span class="lineno">  430</span>  <span class="keyword">using </span>boost::dynamic_pointer_cast;</div>
<div class="line"><a id="l00431" name="l00431"></a><span class="lineno">  431</span>  <span class="keyword">using </span>boost::shared_ptr;</div>
<div class="line"><a id="l00432" name="l00432"></a><span class="lineno">  432</span>  <span class="keyword">using </span>boost::asio::const_buffer;</div>
<div class="line"><a id="l00433" name="l00433"></a><span class="lineno">  433</span>  <span class="keyword">using </span>std::type_index;</div>
<div class="line"><a id="l00434" name="l00434"></a><span class="lineno">  434</span> </div>
<div class="line"><a id="l00435" name="l00435"></a><span class="lineno">  435</span>  <span class="comment">// We are in thread W.</span></div>
<div class="line"><a id="l00436" name="l00436"></a><span class="lineno">  436</span> </div>
<div class="line"><a id="l00437" name="l00437"></a><span class="lineno">  437</span>  <span class="comment">// Save before *packet_data potentially annihilated.</span></div>
<div class="line"><a id="l00438" name="l00438"></a><span class="lineno">  438</span>  <span class="keyword">const</span> <span class="keywordtype">size_t</span> packet_data_size = packet_data-&gt;size();</div>
<div class="line"><a id="l00439" name="l00439"></a><span class="lineno">  439</span> </div>
<div class="line"><a id="l00440" name="l00440"></a><span class="lineno">  440</span>  <span class="comment">/* `packet_data` contains packet binary data.  Deserialize it into a structure and handle it.</span></div>
<div class="line"><a id="l00441" name="l00441"></a><span class="lineno">  441</span><span class="comment">   *</span></div>
<div class="line"><a id="l00442" name="l00442"></a><span class="lineno">  442</span><span class="comment">   * Discussion of 2nd argument (m_dyn_guarantee_one_low_lvl_in_buf_per_socket option):</span></div>
<div class="line"><a id="l00443" name="l00443"></a><span class="lineno">  443</span><span class="comment">   * For simplicity, suppose only DATA packets exist (they are the biggest, easily, in practice).</span></div>
<div class="line"><a id="l00444" name="l00444"></a><span class="lineno">  444</span><span class="comment">   * Further suppose that m_dyn_low_lvl_max_packet_size = 32k, m_st_max_block_size = 1k.</span></div>
<div class="line"><a id="l00445" name="l00445"></a><span class="lineno">  445</span><span class="comment">   *</span></div>
<div class="line"><a id="l00446" name="l00446"></a><span class="lineno">  446</span><span class="comment">   * If the arg is set to true, then the low-level UDP input code will allocate a 32k buffer exactly once per Node;</span></div>
<div class="line"><a id="l00447" name="l00447"></a><span class="lineno">  447</span><span class="comment">   * read up to 1k (+header overhead) into it.  Then DATA deserializer will copy the sub-sequence within that</span></div>
<div class="line"><a id="l00448" name="l00448"></a><span class="lineno">  448</span><span class="comment">   * up-to-1k-ish prefix of the 32k buffer that stores the actual DATA payload (which will be vast majority of</span></div>
<div class="line"><a id="l00449" name="l00449"></a><span class="lineno">  449</span><span class="comment">   * that up-to-1k) into a newly allocated buffer for that packet.  (This copy will then be moved around, to the</span></div>
<div class="line"><a id="l00450" name="l00450"></a><span class="lineno">  450</span><span class="comment">   * extent possible, eventually ending up [probably copied, ultimately] in the user&#39;s data structure of choice,</span></div>
<div class="line"><a id="l00451" name="l00451"></a><span class="lineno">  451</span><span class="comment">   * presumably first living in Receive buffer for the appropriate socket.)  Then for the next incoming packet,</span></div>
<div class="line"><a id="l00452" name="l00452"></a><span class="lineno">  452</span><span class="comment">   * the same original 32k buffer will be reused to store the deserialized data again; rinse/repeat.</span></div>
<div class="line"><a id="l00453" name="l00453"></a><span class="lineno">  453</span><span class="comment">   * So the total comes to: 1 32k allocation and deallocation; N up-to-1k allocations and deallocations; and</span></div>
<div class="line"><a id="l00454" name="l00454"></a><span class="lineno">  454</span><span class="comment">   * N up-to-1k copies; where N is # of DATA packets received (could be huge).</span></div>
<div class="line"><a id="l00455" name="l00455"></a><span class="lineno">  455</span><span class="comment">   *</span></div>
<div class="line"><a id="l00456" name="l00456"></a><span class="lineno">  456</span><span class="comment">   * If the arg is set to false, then the low-level UDP input code will allocate a 32k buffer once per DATA packet;</span></div>
<div class="line"><a id="l00457" name="l00457"></a><span class="lineno">  457</span><span class="comment">   * read up to 1k (+header overhead) into it.  Then DATA deserializer will MOVE the entire up-to-32k buffer including</span></div>
<div class="line"><a id="l00458" name="l00458"></a><span class="lineno">  458</span><span class="comment">   * up-to-1k-ish prefix within it that stores the actual DATA payload (which will be vast majority of</span></div>
<div class="line"><a id="l00459" name="l00459"></a><span class="lineno">  459</span><span class="comment">   * that up-to-1k) into the place where deserialized data are stored.  (This buffer (and information about which part</span></div>
<div class="line"><a id="l00460" name="l00460"></a><span class="lineno">  460</span><span class="comment">   * of it the actual DATA payload) will then be moved around, to the extent possible, eventually ending up [probably</span></div>
<div class="line"><a id="l00461" name="l00461"></a><span class="lineno">  461</span><span class="comment">   * copied, ultimately] in the user&#39;s data structure of choice, presumably first living in Receive buffer for the</span></div>
<div class="line"><a id="l00462" name="l00462"></a><span class="lineno">  462</span><span class="comment">   * appropriate socket.)  Then for the next incoming packet, the low-level UDP input code will have to reallocate</span></div>
<div class="line"><a id="l00463" name="l00463"></a><span class="lineno">  463</span><span class="comment">   * a new 32k buffer, because the deserializer &quot;took&quot; it for its own purpose (without copying it, thinking that&#39;s</span></div>
<div class="line"><a id="l00464" name="l00464"></a><span class="lineno">  464</span><span class="comment">   * faster, which it is -- in that limited context), so it cannot be reused; rinse/repeat.</span></div>
<div class="line"><a id="l00465" name="l00465"></a><span class="lineno">  465</span><span class="comment">   * So the total comes to: N 32k allocations and deallocations; but no copies; and N (quite cheap) moves; where</span></div>
<div class="line"><a id="l00466" name="l00466"></a><span class="lineno">  466</span><span class="comment">   * N is # of DATA packets received (could be huge).</span></div>
<div class="line"><a id="l00467" name="l00467"></a><span class="lineno">  467</span><span class="comment">   *</span></div>
<div class="line"><a id="l00468" name="l00468"></a><span class="lineno">  468</span><span class="comment">   * What is faster?  In practice (assuming a CPU-limited environment, meaning no loss, no delay, and a constant</span></div>
<div class="line"><a id="l00469" name="l00469"></a><span class="lineno">  469</span><span class="comment">   * stream of data being sent and received), at least on a localhost Mac setup, it turns out that the `true` way</span></div>
<div class="line"><a id="l00470" name="l00470"></a><span class="lineno">  470</span><span class="comment">   * is a bit faster, in that throughput is consistently higher by ~5%.  (This should be taken with grain of salt:</span></div>
<div class="line"><a id="l00471" name="l00471"></a><span class="lineno">  471</span><span class="comment">   * improvements in other areas of the code could make this impact become higher in proportion, etc. etc.)</span></div>
<div class="line"><a id="l00472" name="l00472"></a><span class="lineno">  472</span><span class="comment">   * This isn&#39;t too surprising; N-bytes alloc/copy/dealloc is bad, but a 32x-bigger alloca/dealloc can certainly</span></div>
<div class="line"><a id="l00473" name="l00473"></a><span class="lineno">  473</span><span class="comment">   * be worse.</span></div>
<div class="line"><a id="l00474" name="l00474"></a><span class="lineno">  474</span><span class="comment">   *</span></div>
<div class="line"><a id="l00475" name="l00475"></a><span class="lineno">  475</span><span class="comment">   * However, suppose we lower knob for &quot;32k&quot; to ~1k.  Then we have, essentially:</span></div>
<div class="line"><a id="l00476" name="l00476"></a><span class="lineno">  476</span><span class="comment">   * true =&gt; N 1k x alloc/copy/dealloc;</span></div>
<div class="line"><a id="l00477" name="l00477"></a><span class="lineno">  477</span><span class="comment">   * false =&gt; N 1k alloc/dealloc.</span></div>
<div class="line"><a id="l00478" name="l00478"></a><span class="lineno">  478</span><span class="comment">   *</span></div>
<div class="line"><a id="l00479" name="l00479"></a><span class="lineno">  479</span><span class="comment">   * In this case `false` might be somewhat better.  The good thing is that, as of this writing, all these values</span></div>
<div class="line"><a id="l00480" name="l00480"></a><span class="lineno">  480</span><span class="comment">   * have option knobs.  Of course, all this is subject to change and/or become automated over time.</span></div>
<div class="line"><a id="l00481" name="l00481"></a><span class="lineno">  481</span><span class="comment">   *</span></div>
<div class="line"><a id="l00482" name="l00482"></a><span class="lineno">  482</span><span class="comment">   * A huge caveat about the above discussion: Not all of the allocs/copies/deallocs occur in the same thread,</span></div>
<div class="line"><a id="l00483" name="l00483"></a><span class="lineno">  483</span><span class="comment">   * so in a multi-core environment, throughput might be improved by parallelism vs. the implications of above text.</span></div>
<div class="line"><a id="l00484" name="l00484"></a><span class="lineno">  484</span><span class="comment">   * Above could be rewritten to account for this; but at the moment the above should at least elucidate the issues</span></div>
<div class="line"><a id="l00485" name="l00485"></a><span class="lineno">  485</span><span class="comment">   * involved sufficiently for the reader to reason about this on their own. */</span></div>
<div class="line"><a id="l00486" name="l00486"></a><span class="lineno">  486</span>  <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Low_lvl_packet::Ptr</a> packet</div>
<div class="line"><a id="l00487" name="l00487"></a><span class="lineno">  487</span>    = <a class="code hl_function" href="structflow_1_1net__flow_1_1Low__lvl__packet.html#a186d7dae0c4b4402aed22a25d595ed30">Low_lvl_packet::create_from_raw_data_packet</a>(<a class="code hl_function" href="classflow_1_1log_1_1Log__context.html#af4db395042b065b00398cd59845dcb4d">get_logger</a>(), packet_data,</div>
<div class="line"><a id="l00488" name="l00488"></a><span class="lineno">  488</span>                                                  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a43c42121d48a55a43a48e3a84bd10595">opt</a>(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a>.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#ad041b807fddff912fd6f302abeb88a2f">m_dyn_guarantee_one_low_lvl_in_buf_per_socket</a>));</div>
<div class="line"><a id="l00489" name="l00489"></a><span class="lineno">  489</span>  <span class="comment">// ^-- That logged as much or as little as appropriate (we need not).  null if error. `packet_data` may be blown away.</span></div>
<div class="line"><a id="l00490" name="l00490"></a><span class="lineno">  490</span> </div>
<div class="line"><a id="l00491" name="l00491"></a><span class="lineno">  491</span>  <span class="keywordflow">if</span> (!packet)</div>
<div class="line"><a id="l00492" name="l00492"></a><span class="lineno">  492</span>  {</div>
<div class="line"><a id="l00493" name="l00493"></a><span class="lineno">  493</span>    <span class="keywordflow">return</span>; <span class="comment">// As advertised, caller is free to do anything they want to *packet_data now (e.g., read another packet).</span></div>
<div class="line"><a id="l00494" name="l00494"></a><span class="lineno">  494</span>  }</div>
<div class="line"><a id="l00495" name="l00495"></a><span class="lineno">  495</span> </div>
<div class="line"><a id="l00496" name="l00496"></a><span class="lineno">  496</span>  <span class="keyword">const</span> <span class="keyword">auto</span>&amp; packet_ref = *packet;</div>
<div class="line"><a id="l00497" name="l00497"></a><span class="lineno">  497</span> </div>
<div class="line"><a id="l00498" name="l00498"></a><span class="lineno">  498</span>  <span class="comment">/* Preliminary notes for the rest of this important method:</span></div>
<div class="line"><a id="l00499" name="l00499"></a><span class="lineno">  499</span><span class="comment">   * - Invalid fields:  If some field in the packet is simply erroneous, such as</span></div>
<div class="line"><a id="l00500" name="l00500"></a><span class="lineno">  500</span><span class="comment">   *   a negative number where a positive number is expected or something, the packet is</span></div>
<div class="line"><a id="l00501" name="l00501"></a><span class="lineno">  501</span><span class="comment">   *   simply dropped.  No RST is sent and no error is reported to the user (other than a log</span></div>
<div class="line"><a id="l00502" name="l00502"></a><span class="lineno">  502</span><span class="comment">   *   message).  This is similar to what at least the Zaghal/Khan FSM model for TCP describes, and</span></div>
<div class="line"><a id="l00503" name="l00503"></a><span class="lineno">  503</span><span class="comment">   *   it seems reasonable (and easy).  This only applies to fields that could never be right in any</span></div>
<div class="line"><a id="l00504" name="l00504"></a><span class="lineno">  504</span><span class="comment">   *   situation.</span></div>
<div class="line"><a id="l00505" name="l00505"></a><span class="lineno">  505</span><span class="comment">   * - Other errors:  More likely are other error situations, such as receiving a SYN to a socket</span></div>
<div class="line"><a id="l00506" name="l00506"></a><span class="lineno">  506</span><span class="comment">   *   that&#39;s in SYN_SENT state.  Since such problems can be a result of delayed packets or other</span></div>
<div class="line"><a id="l00507" name="l00507"></a><span class="lineno">  507</span><span class="comment">   *   conditions, there are various possibilities for response.  Examples:</span></div>
<div class="line"><a id="l00508" name="l00508"></a><span class="lineno">  508</span><span class="comment">   *   - Example: Getting SYN in SYN_SENT: always illegal but could happen due to delayed packets or</span></div>
<div class="line"><a id="l00509" name="l00509"></a><span class="lineno">  509</span><span class="comment">   *     freak coincidences; send RST and close connection.</span></div>
<div class="line"><a id="l00510" name="l00510"></a><span class="lineno">  510</span><span class="comment">   *   - Example: Getting SYN on a non-listening port: common error situation; send RST.</span></div>
<div class="line"><a id="l00511" name="l00511"></a><span class="lineno">  511</span><span class="comment">   *   - Example: Getting SYN_ACK twice: duplicate packet or result of loss; send SYN_ACK_ACK</span></div>
<div class="line"><a id="l00512" name="l00512"></a><span class="lineno">  512</span><span class="comment">   *     again and continue normally.</span></div>
<div class="line"><a id="l00513" name="l00513"></a><span class="lineno">  513</span><span class="comment">   *   - Example: Getting RST in ESTABLISHED: other side is resetting connection.  Close connection;</span></div>
<div class="line"><a id="l00514" name="l00514"></a><span class="lineno">  514</span><span class="comment">   *     don&#39;t respond with RST. */</span></div>
<div class="line"><a id="l00515" name="l00515"></a><span class="lineno">  515</span> </div>
<div class="line"><a id="l00516" name="l00516"></a><span class="lineno">  516</span>  <span class="comment">// Sanity-check basic fields.</span></div>
<div class="line"><a id="l00517" name="l00517"></a><span class="lineno">  517</span> </div>
<div class="line"><a id="l00518" name="l00518"></a><span class="lineno">  518</span>  <span class="comment">// Sanity-check source and destination Flow ports.</span></div>
<div class="line"><a id="l00519" name="l00519"></a><span class="lineno">  519</span>  <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1net__flow.html#a079d8cd87a68d1c5f04c6bce71f0061d">flow_port_t</a> flow_local_port = packet-&gt;m_packed.m_dst_port;</div>
<div class="line"><a id="l00520" name="l00520"></a><span class="lineno">  520</span>  <span class="keyword">const</span> <a class="code hl_typedef" href="namespaceflow_1_1net__flow.html#a079d8cd87a68d1c5f04c6bce71f0061d">flow_port_t</a> flow_remote_port = packet-&gt;m_packed.m_src_port;</div>
<div class="line"><a id="l00521" name="l00521"></a><span class="lineno">  521</span>  <span class="keywordflow">if</span> (flow_remote_port == <a class="code hl_variable" href="namespaceflow_1_1net__flow.html#a9dd0c9d8de00fab78d8b0a3f50dad2a9">S_PORT_ANY</a>)</div>
<div class="line"><a id="l00522" name="l00522"></a><span class="lineno">  522</span>  {</div>
<div class="line"><a id="l00523" name="l00523"></a><span class="lineno">  523</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Invalid src_port value [&quot;</span> &lt;&lt; <a class="code hl_variable" href="namespaceflow_1_1net__flow.html#a9dd0c9d8de00fab78d8b0a3f50dad2a9">S_PORT_ANY</a> &lt;&lt; <span class="stringliteral">&quot;] from [UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;].  &quot;</span></div>
<div class="line"><a id="l00524" name="l00524"></a><span class="lineno">  524</span>                     <span class="stringliteral">&quot;Dropping packet.&quot;</span>);</div>
<div class="line"><a id="l00525" name="l00525"></a><span class="lineno">  525</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00526" name="l00526"></a><span class="lineno">  526</span>  }</div>
<div class="line"><a id="l00527" name="l00527"></a><span class="lineno">  527</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l00528" name="l00528"></a><span class="lineno">  528</span>  <span class="keywordflow">if</span> (flow_local_port == <a class="code hl_variable" href="namespaceflow_1_1net__flow.html#a9dd0c9d8de00fab78d8b0a3f50dad2a9">S_PORT_ANY</a>)</div>
<div class="line"><a id="l00529" name="l00529"></a><span class="lineno">  529</span>  {</div>
<div class="line"><a id="l00530" name="l00530"></a><span class="lineno">  530</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Invalid dst_port value [&quot;</span> &lt;&lt; <a class="code hl_variable" href="namespaceflow_1_1net__flow.html#a9dd0c9d8de00fab78d8b0a3f50dad2a9">S_PORT_ANY</a> &lt;&lt; <span class="stringliteral">&quot;] from [UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;].  &quot;</span></div>
<div class="line"><a id="l00531" name="l00531"></a><span class="lineno">  531</span>                     <span class="stringliteral">&quot;Dropping packet.&quot;</span>);</div>
<div class="line"><a id="l00532" name="l00532"></a><span class="lineno">  532</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00533" name="l00533"></a><span class="lineno">  533</span>  }</div>
<div class="line"><a id="l00534" name="l00534"></a><span class="lineno">  534</span> </div>
<div class="line"><a id="l00535" name="l00535"></a><span class="lineno">  535</span>  <span class="comment">// Sanity-check data size.  Should be guaranteed during deserialization.</span></div>
<div class="line"><a id="l00536" name="l00536"></a><span class="lineno">  536</span>  assert((<span class="keyword">typeid</span>(packet_ref) != <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Data__packet.html">Data_packet</a>)) ||</div>
<div class="line"><a id="l00537" name="l00537"></a><span class="lineno">  537</span>         (!(static_pointer_cast&lt;const Data_packet&gt;(packet)-&gt;m_data.empty())));</div>
<div class="line"><a id="l00538" name="l00538"></a><span class="lineno">  538</span> </div>
<div class="line"><a id="l00539" name="l00539"></a><span class="lineno">  539</span>  <span class="comment">// Demultiplex to proper destination socket; and handle according to state machine.</span></div>
<div class="line"><a id="l00540" name="l00540"></a><span class="lineno">  540</span> </div>
<div class="line"><a id="l00541" name="l00541"></a><span class="lineno">  541</span>  <span class="comment">/* Check if destination port is to a peer-to-peer socket.</span></div>
<div class="line"><a id="l00542" name="l00542"></a><span class="lineno">  542</span><span class="comment">   * It&#39;s important to check for this before checking whether the port matches a listening server</span></div>
<div class="line"><a id="l00543" name="l00543"></a><span class="lineno">  543</span><span class="comment">   * socket.  Example: server S listens on port 80 (so m_servs[80] exists); client C at remote</span></div>
<div class="line"><a id="l00544" name="l00544"></a><span class="lineno">  544</span><span class="comment">   * endpoint R connects to S:80 (so now m_socks[R, 80] also exists); then client C sends a data</span></div>
<div class="line"><a id="l00545" name="l00545"></a><span class="lineno">  545</span><span class="comment">   * packet to S:80.  Should this go to S:[R, 80] or S:80?  Clearly the former.</span></div>
<div class="line"><a id="l00546" name="l00546"></a><span class="lineno">  546</span><span class="comment">   *</span></div>
<div class="line"><a id="l00547" name="l00547"></a><span class="lineno">  547</span><span class="comment">   * The only caveat is: what if client C1 also wants to now connect S:80?  With this algorithm this</span></div>
<div class="line"><a id="l00548" name="l00548"></a><span class="lineno">  548</span><span class="comment">   * will go to S:80, which is good.  However what if C1&#39;s address is C1:R?  Then that SYN would</span></div>
<div class="line"><a id="l00549" name="l00549"></a><span class="lineno">  549</span><span class="comment">   * erroneously go to the existing peer-to-peer socket S:[R, 80].  However that means somehow 2</span></div>
<div class="line"><a id="l00550" name="l00550"></a><span class="lineno">  550</span><span class="comment">   * sockets bound to the same port and thus the same remote endpoint which shouldn&#39;t happen. */</span></div>
<div class="line"><a id="l00551" name="l00551"></a><span class="lineno">  551</span>  <span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html">Socket_id</a> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>{ { low_lvl_remote_endpoint, flow_remote_port }, flow_local_port };</div>
<div class="line"><a id="l00552" name="l00552"></a><span class="lineno">  552</span>  Socket_id_to_socket_map::const_iterator sock_entry = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>.find(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>);</div>
<div class="line"><a id="l00553" name="l00553"></a><span class="lineno">  553</span>  <span class="keywordflow">if</span> (sock_entry != <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>.end())</div>
<div class="line"><a id="l00554" name="l00554"></a><span class="lineno">  554</span>  {</div>
<div class="line"><a id="l00555" name="l00555"></a><span class="lineno">  555</span>    <span class="comment">// Successful demultiplex to a peer socket.</span></div>
<div class="line"><a id="l00556" name="l00556"></a><span class="lineno">  556</span>    <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Peer_socket::Ptr</a> sock = sock_entry-&gt;second;</div>
<div class="line"><a id="l00557" name="l00557"></a><span class="lineno">  557</span> </div>
<div class="line"><a id="l00558" name="l00558"></a><span class="lineno">  558</span>    <span class="comment">/* Record packet size, type in stats of the socket, now that we know the latter.  (What if sock unknown?</span></div>
<div class="line"><a id="l00559" name="l00559"></a><span class="lineno">  559</span><span class="comment">     * See below.) */</span></div>
<div class="line"><a id="l00560" name="l00560"></a><span class="lineno">  560</span>    sock-&gt;m_rcv_stats.low_lvl_packet(<span class="keyword">typeid</span>(packet_ref), packet_data_size);</div>
<div class="line"><a id="l00561" name="l00561"></a><span class="lineno">  561</span> </div>
<div class="line"><a id="l00562" name="l00562"></a><span class="lineno">  562</span>    <span class="comment">// state cannot change unless this thread W changes it, so no need to lock object across the below code.</span></div>
<div class="line"><a id="l00563" name="l00563"></a><span class="lineno">  563</span>    <span class="keyword">const</span> <a class="code hl_enumeration" href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880f">Peer_socket::Int_state</a> state = sock-&gt;m_int_state;</div>
<div class="line"><a id="l00564" name="l00564"></a><span class="lineno">  564</span> </div>
<div class="line"><a id="l00565" name="l00565"></a><span class="lineno">  565</span>    <span class="comment">/* A little bit of extra validation.  Could not check against max_block_size before</span></div>
<div class="line"><a id="l00566" name="l00566"></a><span class="lineno">  566</span><span class="comment">     * demuxing the socket, as it&#39;s a per-socket option. */</span></div>
<div class="line"><a id="l00567" name="l00567"></a><span class="lineno">  567</span>    <span class="keyword">const</span> <span class="keywordtype">size_t</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a> = sock-&gt;max_block_size();</div>
<div class="line"><a id="l00568" name="l00568"></a><span class="lineno">  568</span> </div>
<div class="line"><a id="l00569" name="l00569"></a><span class="lineno">  569</span>    {</div>
<div class="line"><a id="l00570" name="l00570"></a><span class="lineno">  570</span>      shared_ptr&lt;Data_packet&gt; data;</div>
<div class="line"><a id="l00571" name="l00571"></a><span class="lineno">  571</span>      shared_ptr&lt;Ack_packet&gt; ack;</div>
<div class="line"><a id="l00572" name="l00572"></a><span class="lineno">  572</span>      shared_ptr&lt;Syn_packet&gt; syn;</div>
<div class="line"><a id="l00573" name="l00573"></a><span class="lineno">  573</span>      shared_ptr&lt;Syn_ack_packet&gt; syn_ack;</div>
<div class="line"><a id="l00574" name="l00574"></a><span class="lineno">  574</span> </div>
<div class="line"><a id="l00575" name="l00575"></a><span class="lineno">  575</span>      <span class="comment">/* Perform any tweaks and checks based on the new (for this packet) knowledge that is the identity of `sock`.</span></div>
<div class="line"><a id="l00576" name="l00576"></a><span class="lineno">  576</span><span class="comment">       *</span></div>
<div class="line"><a id="l00577" name="l00577"></a><span class="lineno">  577</span><span class="comment">       * One tweak in particular that applies to multiple packet types as done below:</span></div>
<div class="line"><a id="l00578" name="l00578"></a><span class="lineno">  578</span><span class="comment">       * Every Sequence_number stored therein can be more conveniently logged as relative to the ISN (so 0, 1, etc.</span></div>
<div class="line"><a id="l00579" name="l00579"></a><span class="lineno">  579</span><span class="comment">       * instead of some huge 64-bit thing) as well as a multiple of max-block-size (so 2x8192, 3x8192, etc.; as opposed</span></div>
<div class="line"><a id="l00580" name="l00580"></a><span class="lineno">  580</span><span class="comment">       * to the actual results of those products).  Now that we know `sock`, we can apply those values from it</span></div>
<div class="line"><a id="l00581" name="l00581"></a><span class="lineno">  581</span><span class="comment">       * to the known Sequence_number members, so that they are logged nicely instead of 64-bit monstrosities.</span></div>
<div class="line"><a id="l00582" name="l00582"></a><span class="lineno">  582</span><span class="comment">       * Nuance: you&#39;ll note (ISN + 1) popping up repeatedly; the `+ 1` is explained in class Sequence_number doc header</span></div>
<div class="line"><a id="l00583" name="l00583"></a><span class="lineno">  583</span><span class="comment">       * near *Metadata* discussion. */</span></div>
<div class="line"><a id="l00584" name="l00584"></a><span class="lineno">  584</span>      <span class="keywordflow">if</span> ((data = dynamic_pointer_cast&lt;Data_packet&gt;(packet)))</div>
<div class="line"><a id="l00585" name="l00585"></a><span class="lineno">  585</span>      {</div>
<div class="line"><a id="l00586" name="l00586"></a><span class="lineno">  586</span>        <span class="comment">// If it IS a DATA packet, and its contained data field is too large....</span></div>
<div class="line"><a id="l00587" name="l00587"></a><span class="lineno">  587</span>        <span class="keywordflow">if</span> (data-&gt;m_data.size() &gt; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a>)</div>
<div class="line"><a id="l00588" name="l00588"></a><span class="lineno">  588</span>        {</div>
<div class="line"><a id="l00589" name="l00589"></a><span class="lineno">  589</span>          <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] targeted at [&quot;</span> &lt;&lt; sock &lt;&lt; <span class="stringliteral">&quot;] in &quot;</span></div>
<div class="line"><a id="l00590" name="l00590"></a><span class="lineno">  590</span>                           <span class="stringliteral">&quot;state [&quot;</span> &lt;&lt; state &lt;&lt; <span class="stringliteral">&quot;] has data size [&quot;</span> &lt;&lt; data-&gt;m_data.size() &lt;&lt; <span class="stringliteral">&quot;] exceeding &quot;</span></div>
<div class="line"><a id="l00591" name="l00591"></a><span class="lineno">  591</span>                           <span class="stringliteral">&quot;maximum block size [&quot;</span> &lt;&lt; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a> &lt;&lt; <span class="stringliteral">&quot;].  Dropping packet.&quot;</span>);</div>
<div class="line"><a id="l00592" name="l00592"></a><span class="lineno">  592</span>          <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00593" name="l00593"></a><span class="lineno">  593</span>        }</div>
<div class="line"><a id="l00594" name="l00594"></a><span class="lineno">  594</span> </div>
<div class="line"><a id="l00595" name="l00595"></a><span class="lineno">  595</span>        data-&gt;m_seq_num.set_metadata(<span class="charliteral">&#39;R&#39;</span>, sock-&gt;m_rcv_init_seq_num + 1, <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a>);</div>
<div class="line"><a id="l00596" name="l00596"></a><span class="lineno">  596</span>      }</div>
<div class="line"><a id="l00597" name="l00597"></a><span class="lineno">  597</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((ack = dynamic_pointer_cast&lt;Ack_packet&gt;(packet)))</div>
<div class="line"><a id="l00598" name="l00598"></a><span class="lineno">  598</span>      {</div>
<div class="line"><a id="l00599" name="l00599"></a><span class="lineno">  599</span>        <span class="keywordflow">for</span> (<span class="keyword">const</span> <a class="code hl_typedef" href="structflow_1_1net__flow_1_1Ack__packet_1_1Individual__ack.html#abbd41e30089125f67667b39f5756c275">Ack_packet::Individual_ack::Ptr</a>&amp; individual_ack : ack-&gt;m_rcv_acked_packets)</div>
<div class="line"><a id="l00600" name="l00600"></a><span class="lineno">  600</span>        {</div>
<div class="line"><a id="l00601" name="l00601"></a><span class="lineno">  601</span>          individual_ack-&gt;m_seq_num.set_metadata(<span class="charliteral">&#39;L&#39;</span>, sock-&gt;m_snd_init_seq_num + 1, <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a>);</div>
<div class="line"><a id="l00602" name="l00602"></a><span class="lineno">  602</span>        }</div>
<div class="line"><a id="l00603" name="l00603"></a><span class="lineno">  603</span>      }</div>
<div class="line"><a id="l00604" name="l00604"></a><span class="lineno">  604</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((syn = dynamic_pointer_cast&lt;Syn_packet&gt;(packet)))</div>
<div class="line"><a id="l00605" name="l00605"></a><span class="lineno">  605</span>      {</div>
<div class="line"><a id="l00606" name="l00606"></a><span class="lineno">  606</span>        syn-&gt;m_init_seq_num.set_metadata(<span class="charliteral">&#39;R&#39;</span>, syn-&gt;m_init_seq_num + 1, <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a>);</div>
<div class="line"><a id="l00607" name="l00607"></a><span class="lineno">  607</span>      }</div>
<div class="line"><a id="l00608" name="l00608"></a><span class="lineno">  608</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> ((syn_ack = dynamic_pointer_cast&lt;Syn_ack_packet&gt;(packet)))</div>
<div class="line"><a id="l00609" name="l00609"></a><span class="lineno">  609</span>      {</div>
<div class="line"><a id="l00610" name="l00610"></a><span class="lineno">  610</span>        syn_ack-&gt;m_init_seq_num.set_metadata(<span class="charliteral">&#39;R&#39;</span>, syn_ack-&gt;m_init_seq_num + 1, <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">max_block_size</a>);</div>
<div class="line"><a id="l00611" name="l00611"></a><span class="lineno">  611</span>      }</div>
<div class="line"><a id="l00612" name="l00612"></a><span class="lineno">  612</span>    }</div>
<div class="line"><a id="l00613" name="l00613"></a><span class="lineno">  613</span> </div>
<div class="line"><a id="l00614" name="l00614"></a><span class="lineno">  614</span>    <span class="comment">// else</span></div>
<div class="line"><a id="l00615" name="l00615"></a><span class="lineno">  615</span> </div>
<div class="line"><a id="l00616" name="l00616"></a><span class="lineno">  616</span>    <span class="keywordtype">bool</span> reply_with_rst = <span class="keyword">false</span>;</div>
<div class="line"><a id="l00617" name="l00617"></a><span class="lineno">  617</span>    <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> err_code; <span class="comment">// Initialize to success.</span></div>
<div class="line"><a id="l00618" name="l00618"></a><span class="lineno">  618</span> </div>
<div class="line"><a id="l00619" name="l00619"></a><span class="lineno">  619</span>    <span class="keywordflow">switch</span> (state)</div>
<div class="line"><a id="l00620" name="l00620"></a><span class="lineno">  620</span>    {</div>
<div class="line"><a id="l00621" name="l00621"></a><span class="lineno">  621</span>    <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa20112c63421f4aa5d77b5d5ba5b10c87">Peer_socket::Int_state::S_SYN_SENT</a>:</div>
<div class="line"><a id="l00622" name="l00622"></a><span class="lineno">  622</span>    {</div>
<div class="line"><a id="l00623" name="l00623"></a><span class="lineno">  623</span>      <span class="comment">// We&#39;re in SYN_SENT state: awaiting SYN_ACK.</span></div>
<div class="line"><a id="l00624" name="l00624"></a><span class="lineno">  624</span>      <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__packet.html">Syn_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00625" name="l00625"></a><span class="lineno">  625</span>      {</div>
<div class="line"><a id="l00626" name="l00626"></a><span class="lineno">  626</span>        <span class="comment">/* Replying to SYN with SYN is not allowed.  We don&#39;t support simultaneous active opens.</span></div>
<div class="line"><a id="l00627" name="l00627"></a><span class="lineno">  627</span><span class="comment">         * (RFC 793 does, but it&#39;s not a mainstream situation.)  In fact one would have to perform</span></div>
<div class="line"><a id="l00628" name="l00628"></a><span class="lineno">  628</span><span class="comment">         * Node::connect() while binding to a service port, which we do not allow.</span></div>
<div class="line"><a id="l00629" name="l00629"></a><span class="lineno">  629</span><span class="comment">         *</span></div>
<div class="line"><a id="l00630" name="l00630"></a><span class="lineno">  630</span><span class="comment">         * Another possibility is that this SYN is from some previous connection with the same</span></div>
<div class="line"><a id="l00631" name="l00631"></a><span class="lineno">  631</span><span class="comment">         * socket pair, and we should disregard (no RST) it via sequence number checking.  For now</span></div>
<div class="line"><a id="l00632" name="l00632"></a><span class="lineno">  632</span><span class="comment">         * we assume our port reservation scheme on both ends eliminates socket pair reuse in this</span></div>
<div class="line"><a id="l00633" name="l00633"></a><span class="lineno">  633</span><span class="comment">         * way and thus don&#39;t check for this.</span></div>
<div class="line"><a id="l00634" name="l00634"></a><span class="lineno">  634</span><span class="comment">         *</span></div>
<div class="line"><a id="l00635" name="l00635"></a><span class="lineno">  635</span><span class="comment">         * So, other side is misbehaving.  Send RST and close connection. */</span></div>
<div class="line"><a id="l00636" name="l00636"></a><span class="lineno">  636</span>        err_code =  <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00637" name="l00637"></a><span class="lineno">  637</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00638" name="l00638"></a><span class="lineno">  638</span>      }</div>
<div class="line"><a id="l00639" name="l00639"></a><span class="lineno">  639</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__ack__packet.html">Syn_ack_ack_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00640" name="l00640"></a><span class="lineno">  640</span>      {</div>
<div class="line"><a id="l00641" name="l00641"></a><span class="lineno">  641</span>        <span class="comment">// Similar to SYN.  We should be sending SYN_ACK_ACK (later) -- not they.</span></div>
<div class="line"><a id="l00642" name="l00642"></a><span class="lineno">  642</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00643" name="l00643"></a><span class="lineno">  643</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00644" name="l00644"></a><span class="lineno">  644</span>      }</div>
<div class="line"><a id="l00645" name="l00645"></a><span class="lineno">  645</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Data__packet.html">Data_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00646" name="l00646"></a><span class="lineno">  646</span>      {</div>
<div class="line"><a id="l00647" name="l00647"></a><span class="lineno">  647</span>        <span class="comment">// Similar to SYN.  Should not be getting DATA yet -- must complete handshake first.</span></div>
<div class="line"><a id="l00648" name="l00648"></a><span class="lineno">  648</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00649" name="l00649"></a><span class="lineno">  649</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00650" name="l00650"></a><span class="lineno">  650</span>      }</div>
<div class="line"><a id="l00651" name="l00651"></a><span class="lineno">  651</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Ack__packet.html">Ack_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00652" name="l00652"></a><span class="lineno">  652</span>      {</div>
<div class="line"><a id="l00653" name="l00653"></a><span class="lineno">  653</span>        <span class="comment">// Similar to DATA.</span></div>
<div class="line"><a id="l00654" name="l00654"></a><span class="lineno">  654</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00655" name="l00655"></a><span class="lineno">  655</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00656" name="l00656"></a><span class="lineno">  656</span>      }</div>
<div class="line"><a id="l00657" name="l00657"></a><span class="lineno">  657</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Rst__packet.html">Rst_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00658" name="l00658"></a><span class="lineno">  658</span>      {</div>
<div class="line"><a id="l00659" name="l00659"></a><span class="lineno">  659</span>        <span class="comment">/* Sent SYN; received RST.  Could be common: other side may simply not be listening on the</span></div>
<div class="line"><a id="l00660" name="l00660"></a><span class="lineno">  660</span><span class="comment">         * port to which we wanted to connect.  Close connection but don&#39;t reply to RST with RST</span></div>
<div class="line"><a id="l00661" name="l00661"></a><span class="lineno">  661</span><span class="comment">         * (not useful; could cause endless RSTing). */</span></div>
<div class="line"><a id="l00662" name="l00662"></a><span class="lineno">  662</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">error::Code::S_CONN_REFUSED</a>; <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00663" name="l00663"></a><span class="lineno">  663</span>      }</div>
<div class="line"><a id="l00664" name="l00664"></a><span class="lineno">  664</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__packet.html">Syn_ack_packet</a>)) <span class="comment">// To SYN_SENT state.</span></div>
<div class="line"><a id="l00665" name="l00665"></a><span class="lineno">  665</span>      {</div>
<div class="line"><a id="l00666" name="l00666"></a><span class="lineno">  666</span>        <span class="comment">// Sent SYN; received SYN_ACK.  Great.</span></div>
<div class="line"><a id="l00667" name="l00667"></a><span class="lineno">  667</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aa0f9ebea458490c37a38760c8335506c">handle_syn_ack_to_syn_sent</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>,</div>
<div class="line"><a id="l00668" name="l00668"></a><span class="lineno">  668</span>                                   sock,</div>
<div class="line"><a id="l00669" name="l00669"></a><span class="lineno">  669</span>                                   static_pointer_cast&lt;const Syn_ack_packet&gt;(packet));</div>
<div class="line"><a id="l00670" name="l00670"></a><span class="lineno">  670</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00671" name="l00671"></a><span class="lineno">  671</span>      }</div>
<div class="line"><a id="l00672" name="l00672"></a><span class="lineno">  672</span>      <span class="keywordflow">else</span></div>
<div class="line"><a id="l00673" name="l00673"></a><span class="lineno">  673</span>      {</div>
<div class="line"><a id="l00674" name="l00674"></a><span class="lineno">  674</span>        assert(<span class="keyword">false</span>); <span class="comment">// We&#39;ve eliminated this possibility already above.</span></div>
<div class="line"><a id="l00675" name="l00675"></a><span class="lineno">  675</span>      }</div>
<div class="line"><a id="l00676" name="l00676"></a><span class="lineno">  676</span>      <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00677" name="l00677"></a><span class="lineno">  677</span>    } <span class="comment">// case Peer_socket::Int_state::S_SYN_SENT:</span></div>
<div class="line"><a id="l00678" name="l00678"></a><span class="lineno">  678</span> </div>
<div class="line"><a id="l00679" name="l00679"></a><span class="lineno">  679</span>    <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa9838c717b26793d3b5360e4d718dc2d2">Peer_socket::Int_state::S_SYN_RCVD</a>:</div>
<div class="line"><a id="l00680" name="l00680"></a><span class="lineno">  680</span>    {</div>
<div class="line"><a id="l00681" name="l00681"></a><span class="lineno">  681</span>      <span class="comment">// We&#39;re in SYN_RCVD state: awaiting SYN_ACK_ACK.</span></div>
<div class="line"><a id="l00682" name="l00682"></a><span class="lineno">  682</span>      <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__packet.html">Syn_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00683" name="l00683"></a><span class="lineno">  683</span>      {</div>
<div class="line"><a id="l00684" name="l00684"></a><span class="lineno">  684</span>        <span class="comment">/* Replying to SYN_ACK with SYN is not allowed.  However it could be be a duplicated</span></div>
<div class="line"><a id="l00685" name="l00685"></a><span class="lineno">  685</span><span class="comment">         * original SYN (ha ha), in which case it&#39;s not an error and is dropped silently.  Otherwise</span></div>
<div class="line"><a id="l00686" name="l00686"></a><span class="lineno">  686</span><span class="comment">         * it&#39;s an error.</span></div>
<div class="line"><a id="l00687" name="l00687"></a><span class="lineno">  687</span><span class="comment">         *</span></div>
<div class="line"><a id="l00688" name="l00688"></a><span class="lineno">  688</span><span class="comment">         * Another possibility is that this SYN is from some previous connection with the same</span></div>
<div class="line"><a id="l00689" name="l00689"></a><span class="lineno">  689</span><span class="comment">         * socket pair, and we should disregard (no RST) it via sequence number checking.  For now</span></div>
<div class="line"><a id="l00690" name="l00690"></a><span class="lineno">  690</span><span class="comment">         * we assume our port reservation scheme on both ends eliminates socket pair reuse in this</span></div>
<div class="line"><a id="l00691" name="l00691"></a><span class="lineno">  691</span><span class="comment">         * way and thus don&#39;t check for this.</span></div>
<div class="line"><a id="l00692" name="l00692"></a><span class="lineno">  692</span><span class="comment">         *</span></div>
<div class="line"><a id="l00693" name="l00693"></a><span class="lineno">  693</span><span class="comment">         * So, decide if other side is misbehaving.  If so, send RST and close connection.</span></div>
<div class="line"><a id="l00694" name="l00694"></a><span class="lineno">  694</span><span class="comment">         * Otherwise ignore. */</span></div>
<div class="line"><a id="l00695" name="l00695"></a><span class="lineno">  695</span>        <span class="keywordflow">if</span> (static_pointer_cast&lt;const Syn_packet&gt;(packet)-&gt;m_init_seq_num == sock-&gt;m_rcv_init_seq_num)</div>
<div class="line"><a id="l00696" name="l00696"></a><span class="lineno">  696</span>        {</div>
<div class="line"><a id="l00697" name="l00697"></a><span class="lineno">  697</span>          <span class="comment">// Should be plenty of context if TRACE logging enabled anyway.</span></div>
<div class="line"><a id="l00698" name="l00698"></a><span class="lineno">  698</span>          <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Duplicate valid [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] packet; ignoring.&quot;</span>);</div>
<div class="line"><a id="l00699" name="l00699"></a><span class="lineno">  699</span>        }</div>
<div class="line"><a id="l00700" name="l00700"></a><span class="lineno">  700</span>        <span class="keywordflow">else</span></div>
<div class="line"><a id="l00701" name="l00701"></a><span class="lineno">  701</span>        {</div>
<div class="line"><a id="l00702" name="l00702"></a><span class="lineno">  702</span>          err_code =  <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00703" name="l00703"></a><span class="lineno">  703</span>          reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00704" name="l00704"></a><span class="lineno">  704</span>        }</div>
<div class="line"><a id="l00705" name="l00705"></a><span class="lineno">  705</span>      }</div>
<div class="line"><a id="l00706" name="l00706"></a><span class="lineno">  706</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__packet.html">Syn_ack_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00707" name="l00707"></a><span class="lineno">  707</span>      {</div>
<div class="line"><a id="l00708" name="l00708"></a><span class="lineno">  708</span>        <span class="comment">// SYN_ACK in response to SYN_ACK is always wrong.</span></div>
<div class="line"><a id="l00709" name="l00709"></a><span class="lineno">  709</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00710" name="l00710"></a><span class="lineno">  710</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00711" name="l00711"></a><span class="lineno">  711</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00712" name="l00712"></a><span class="lineno">  712</span>      }</div>
<div class="line"><a id="l00713" name="l00713"></a><span class="lineno">  713</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Data__packet.html">Data_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00714" name="l00714"></a><span class="lineno">  714</span>      {</div>
<div class="line"><a id="l00715" name="l00715"></a><span class="lineno">  715</span>        <span class="comment">/* This is legitimate under loss conditions.  Suppose we are SYN_RCVD, send SYN_ACK, they</span></div>
<div class="line"><a id="l00716" name="l00716"></a><span class="lineno">  716</span><span class="comment">         * receive SYN_ACK, so they go SYN_SENT -&gt; ESTABLISHED, and they send SYN_ACK_ACK.  Now</span></div>
<div class="line"><a id="l00717" name="l00717"></a><span class="lineno">  717</span><span class="comment">         * suppose that SYN_ACK_ACK was dropped.  Now say they send DATA (which they have every</span></div>
<div class="line"><a id="l00718" name="l00718"></a><span class="lineno">  718</span><span class="comment">         * right do to: their state is ESTABLISHED).  So we&#39;ve received DATA, but we&#39;re still in</span></div>
<div class="line"><a id="l00719" name="l00719"></a><span class="lineno">  719</span><span class="comment">         * SYN_RCVD.  It can also happen if DATA and SYN_ACK_ACK are re-ordered by the network. */</span></div>
<div class="line"><a id="l00720" name="l00720"></a><span class="lineno">  720</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#abf80b7de1398e93d1d4289ef5bf2ae2c">handle_data_to_syn_rcvd</a>(sock, static_pointer_cast&lt;Data_packet&gt;(packet));</div>
<div class="line"><a id="l00721" name="l00721"></a><span class="lineno">  721</span>      }</div>
<div class="line"><a id="l00722" name="l00722"></a><span class="lineno">  722</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Ack__packet.html">Ack_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00723" name="l00723"></a><span class="lineno">  723</span>      {</div>
<div class="line"><a id="l00724" name="l00724"></a><span class="lineno">  724</span>        <span class="comment">/* On the other hand, since we are not yet ESTABLISHED, we couldn&#39;t have sent DATA, so we</span></div>
<div class="line"><a id="l00725" name="l00725"></a><span class="lineno">  725</span><span class="comment">         * shouldn&#39;t be getting any ACKs. */</span></div>
<div class="line"><a id="l00726" name="l00726"></a><span class="lineno">  726</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00727" name="l00727"></a><span class="lineno">  727</span>        reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00728" name="l00728"></a><span class="lineno">  728</span>      }</div>
<div class="line"><a id="l00729" name="l00729"></a><span class="lineno">  729</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Rst__packet.html">Rst_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00730" name="l00730"></a><span class="lineno">  730</span>      {</div>
<div class="line"><a id="l00731" name="l00731"></a><span class="lineno">  731</span>        <span class="comment">/* Received SYN; sent SYN_ACK; received RST.  Shouldn&#39;t be common, but they are refusing</span></div>
<div class="line"><a id="l00732" name="l00732"></a><span class="lineno">  732</span><span class="comment">         * connection at this late stage for some reason.</span></div>
<div class="line"><a id="l00733" name="l00733"></a><span class="lineno">  733</span><span class="comment">         *</span></div>
<div class="line"><a id="l00734" name="l00734"></a><span class="lineno">  734</span><span class="comment">         * Close connection but don&#39;t reply to RST with RST (not useful; could cause endless</span></div>
<div class="line"><a id="l00735" name="l00735"></a><span class="lineno">  735</span><span class="comment">         * RSTing). */</span></div>
<div class="line"><a id="l00736" name="l00736"></a><span class="lineno">  736</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">error::Code::S_CONN_REFUSED</a>;</div>
<div class="line"><a id="l00737" name="l00737"></a><span class="lineno">  737</span>      }</div>
<div class="line"><a id="l00738" name="l00738"></a><span class="lineno">  738</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__ack__packet.html">Syn_ack_ack_packet</a>)) <span class="comment">// To SYN_RCVD state.</span></div>
<div class="line"><a id="l00739" name="l00739"></a><span class="lineno">  739</span>      {</div>
<div class="line"><a id="l00740" name="l00740"></a><span class="lineno">  740</span>        <span class="comment">// Sent SYN_ACK; received SYN_ACK_ACK.  Great.</span></div>
<div class="line"><a id="l00741" name="l00741"></a><span class="lineno">  741</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a29d02f9e302c7b06288ff1c644fa8d65">handle_syn_ack_ack_to_syn_rcvd</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>, sock, static_pointer_cast&lt;const Syn_ack_ack_packet&gt;(packet));</div>
<div class="line"><a id="l00742" name="l00742"></a><span class="lineno">  742</span>      }</div>
<div class="line"><a id="l00743" name="l00743"></a><span class="lineno">  743</span>      <span class="keywordflow">else</span></div>
<div class="line"><a id="l00744" name="l00744"></a><span class="lineno">  744</span>      {</div>
<div class="line"><a id="l00745" name="l00745"></a><span class="lineno">  745</span>        assert(<span class="keyword">false</span>); <span class="comment">// We&#39;ve eliminated this possibility already above.</span></div>
<div class="line"><a id="l00746" name="l00746"></a><span class="lineno">  746</span>      }</div>
<div class="line"><a id="l00747" name="l00747"></a><span class="lineno">  747</span>      <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00748" name="l00748"></a><span class="lineno">  748</span>    } <span class="comment">// case Peer_socket::Int_state::S_SYN_RCVD:</span></div>
<div class="line"><a id="l00749" name="l00749"></a><span class="lineno">  749</span> </div>
<div class="line"><a id="l00750" name="l00750"></a><span class="lineno">  750</span>    <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa16fdfce85d7bca9386378acd29eb7202">Peer_socket::Int_state::S_ESTABLISHED</a>:</div>
<div class="line"><a id="l00751" name="l00751"></a><span class="lineno">  751</span>    {</div>
<div class="line"><a id="l00752" name="l00752"></a><span class="lineno">  752</span>      <span class="comment">/* We&#39;re in ESTABLISHED state: will accept DATA and ACKs, etc.  However just because we&#39;ve</span></div>
<div class="line"><a id="l00753" name="l00753"></a><span class="lineno">  753</span><span class="comment">       * ESTABLISHED does not mean they have.  Specifically, suppose we were SYN_SENT, got SYN_ACK,</span></div>
<div class="line"><a id="l00754" name="l00754"></a><span class="lineno">  754</span><span class="comment">       * sent SYN_ACK_ACK, so transferred to ESTABLISHED.  Now suppose that SYN_ACK_ACK was dropped.</span></div>
<div class="line"><a id="l00755" name="l00755"></a><span class="lineno">  755</span><span class="comment">       * We&#39;re ESTABLISHED, but they&#39;re going to resend SYN_ACK due to retransmission timer.</span></div>
<div class="line"><a id="l00756" name="l00756"></a><span class="lineno">  756</span><span class="comment">       * So we must be ready for this resent SYN_ACK, not just DATA and such. */</span></div>
<div class="line"><a id="l00757" name="l00757"></a><span class="lineno">  757</span>      <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__packet.html">Syn_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00758" name="l00758"></a><span class="lineno">  758</span>      {</div>
<div class="line"><a id="l00759" name="l00759"></a><span class="lineno">  759</span>        <span class="comment">/* SYN while in ESTABLISHED is not allowed.  However it could be a duplicated original SYN</span></div>
<div class="line"><a id="l00760" name="l00760"></a><span class="lineno">  760</span><span class="comment">         * (ha ha), in which case it&#39;s not an error and is dropped silently.  Otherwise it&#39;s an</span></div>
<div class="line"><a id="l00761" name="l00761"></a><span class="lineno">  761</span><span class="comment">         * error.</span></div>
<div class="line"><a id="l00762" name="l00762"></a><span class="lineno">  762</span><span class="comment">         *</span></div>
<div class="line"><a id="l00763" name="l00763"></a><span class="lineno">  763</span><span class="comment">         * Another possibility is that this SYN is from some previous connection with the same</span></div>
<div class="line"><a id="l00764" name="l00764"></a><span class="lineno">  764</span><span class="comment">         * socket pair, and we should disregard (no RST) it via sequence number checking.  For now</span></div>
<div class="line"><a id="l00765" name="l00765"></a><span class="lineno">  765</span><span class="comment">         * we assume our port reservation scheme on both ends eliminates socket pair reuse in this</span></div>
<div class="line"><a id="l00766" name="l00766"></a><span class="lineno">  766</span><span class="comment">         * way and thus don&#39;t check for this.</span></div>
<div class="line"><a id="l00767" name="l00767"></a><span class="lineno">  767</span><span class="comment">         *</span></div>
<div class="line"><a id="l00768" name="l00768"></a><span class="lineno">  768</span><span class="comment">         * So, decide if other side is misbehaving.  If so, send RST and close connection.</span></div>
<div class="line"><a id="l00769" name="l00769"></a><span class="lineno">  769</span><span class="comment">         * Otherwise ignore. */</span></div>
<div class="line"><a id="l00770" name="l00770"></a><span class="lineno">  770</span>        <span class="keywordflow">if</span> (static_pointer_cast&lt;const Syn_packet&gt;(packet)-&gt;m_init_seq_num == sock-&gt;m_rcv_init_seq_num)</div>
<div class="line"><a id="l00771" name="l00771"></a><span class="lineno">  771</span>        {</div>
<div class="line"><a id="l00772" name="l00772"></a><span class="lineno">  772</span>          <span class="comment">// Should be plenty of context if TRACE logging enabled anyway.</span></div>
<div class="line"><a id="l00773" name="l00773"></a><span class="lineno">  773</span>          <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Duplicate valid [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] packet; ignoring.&quot;</span>);</div>
<div class="line"><a id="l00774" name="l00774"></a><span class="lineno">  774</span>        }</div>
<div class="line"><a id="l00775" name="l00775"></a><span class="lineno">  775</span>        <span class="keywordflow">else</span></div>
<div class="line"><a id="l00776" name="l00776"></a><span class="lineno">  776</span>        {</div>
<div class="line"><a id="l00777" name="l00777"></a><span class="lineno">  777</span>          err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00778" name="l00778"></a><span class="lineno">  778</span>          reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00779" name="l00779"></a><span class="lineno">  779</span>        }</div>
<div class="line"><a id="l00780" name="l00780"></a><span class="lineno">  780</span>        <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00781" name="l00781"></a><span class="lineno">  781</span>      } <span class="comment">// if (SYN)</span></div>
<div class="line"><a id="l00782" name="l00782"></a><span class="lineno">  782</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__packet.html">Syn_ack_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00783" name="l00783"></a><span class="lineno">  783</span>      {</div>
<div class="line"><a id="l00784" name="l00784"></a><span class="lineno">  784</span>        <span class="comment">/* This could be the corner case above (we are original SYNner, but our SYN_ACK_ACK was</span></div>
<div class="line"><a id="l00785" name="l00785"></a><span class="lineno">  785</span><span class="comment">         * dropped, so they&#39;re resending SYN_ACK, which they think may have been lost).  It could</span></div>
<div class="line"><a id="l00786" name="l00786"></a><span class="lineno">  786</span><span class="comment">         * also just be a duplicate SYN_ACK.  Suppose we respond with SYN_ACK_ACK as before.  If</span></div>
<div class="line"><a id="l00787" name="l00787"></a><span class="lineno">  787</span><span class="comment">         * they&#39;re resending SYN_ACK due to loss, then this is clearly proper; if they get</span></div>
<div class="line"><a id="l00788" name="l00788"></a><span class="lineno">  788</span><span class="comment">         * SYN_ACK_ACK this time, they&#39;re good to go.  If it&#39;s just a duplicate (they&#39;re already</span></div>
<div class="line"><a id="l00789" name="l00789"></a><span class="lineno">  789</span><span class="comment">         * ESTABLISHED), then they&#39;ll similarly just accept SYN_ACK_ACK as a harmless duplicate.</span></div>
<div class="line"><a id="l00790" name="l00790"></a><span class="lineno">  790</span><span class="comment">         * So, that&#39;s fine.</span></div>
<div class="line"><a id="l00791" name="l00791"></a><span class="lineno">  791</span><span class="comment">         *</span></div>
<div class="line"><a id="l00792" name="l00792"></a><span class="lineno">  792</span><span class="comment">         * As usual it can also be an invalid packet, in which case we decide the other side is</span></div>
<div class="line"><a id="l00793" name="l00793"></a><span class="lineno">  793</span><span class="comment">         * misbehaving and RST/close connection. */</span></div>
<div class="line"><a id="l00794" name="l00794"></a><span class="lineno">  794</span> </div>
<div class="line"><a id="l00795" name="l00795"></a><span class="lineno">  795</span>        <span class="keyword">auto</span> syn_ack = static_pointer_cast&lt;const Syn_ack_packet&gt;(packet);</div>
<div class="line"><a id="l00796" name="l00796"></a><span class="lineno">  796</span> </div>
<div class="line"><a id="l00797" name="l00797"></a><span class="lineno">  797</span>        <span class="keywordflow">if</span> (sock-&gt;m_active_connect &amp;&amp; (syn_ack-&gt;m_init_seq_num == sock-&gt;m_rcv_init_seq_num))</div>
<div class="line"><a id="l00798" name="l00798"></a><span class="lineno">  798</span>        {</div>
<div class="line"><a id="l00799" name="l00799"></a><span class="lineno">  799</span>          <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#abb3d760b3c880b41e5a4ee7f2c13fd81">handle_syn_ack_to_established</a>(sock, syn_ack);</div>
<div class="line"><a id="l00800" name="l00800"></a><span class="lineno">  800</span>        }</div>
<div class="line"><a id="l00801" name="l00801"></a><span class="lineno">  801</span>        <span class="keywordflow">else</span></div>
<div class="line"><a id="l00802" name="l00802"></a><span class="lineno">  802</span>        {</div>
<div class="line"><a id="l00803" name="l00803"></a><span class="lineno">  803</span>          err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00804" name="l00804"></a><span class="lineno">  804</span>          reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00805" name="l00805"></a><span class="lineno">  805</span>        }</div>
<div class="line"><a id="l00806" name="l00806"></a><span class="lineno">  806</span>      }</div>
<div class="line"><a id="l00807" name="l00807"></a><span class="lineno">  807</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__ack__ack__packet.html">Syn_ack_ack_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00808" name="l00808"></a><span class="lineno">  808</span>      {</div>
<div class="line"><a id="l00809" name="l00809"></a><span class="lineno">  809</span>        <span class="comment">/* We&#39;re ESTABLISHED but got SYN_ACK_ACK.  Suppose we were the active connector.  Then</span></div>
<div class="line"><a id="l00810" name="l00810"></a><span class="lineno">  810</span><span class="comment">         * SYN_ACK_ACK is simply illegal at all times.  Now suppose we were the passive connectee.</span></div>
<div class="line"><a id="l00811" name="l00811"></a><span class="lineno">  811</span><span class="comment">         * To get to ESTABLISHED, we had to have received SYN_ACK_ACK already.  Therefore this</span></div>
<div class="line"><a id="l00812" name="l00812"></a><span class="lineno">  812</span><span class="comment">         * must be a duplicate SYN_ACK_ACK (assuming it equals the original SYN_ACK_ACK; otherwise</span></div>
<div class="line"><a id="l00813" name="l00813"></a><span class="lineno">  813</span><span class="comment">         * it&#39;s just invalid).</span></div>
<div class="line"><a id="l00814" name="l00814"></a><span class="lineno">  814</span><span class="comment">         *</span></div>
<div class="line"><a id="l00815" name="l00815"></a><span class="lineno">  815</span><span class="comment">         * If it&#39;s a duplicate SYN_ACK_ACK, we just drop it as harmless.  Otherwise the other guy</span></div>
<div class="line"><a id="l00816" name="l00816"></a><span class="lineno">  816</span><span class="comment">         * is misbehaving, so we RST/close. */</span></div>
<div class="line"><a id="l00817" name="l00817"></a><span class="lineno">  817</span>        <span class="keywordflow">if</span> ((!sock-&gt;m_active_connect) &amp;&amp;</div>
<div class="line"><a id="l00818" name="l00818"></a><span class="lineno">  818</span>            (static_pointer_cast&lt;const Syn_ack_ack_packet&gt;(packet)-&gt;m_packed.m_security_token</div>
<div class="line"><a id="l00819" name="l00819"></a><span class="lineno">  819</span>               == sock-&gt;m_security_token))</div>
<div class="line"><a id="l00820" name="l00820"></a><span class="lineno">  820</span>        {</div>
<div class="line"><a id="l00821" name="l00821"></a><span class="lineno">  821</span>          <span class="comment">// Should be plenty of context if TRACE logging enabled anyway.</span></div>
<div class="line"><a id="l00822" name="l00822"></a><span class="lineno">  822</span>          <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;Duplicate valid [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] packet; ignoring.&quot;</span>);</div>
<div class="line"><a id="l00823" name="l00823"></a><span class="lineno">  823</span>        }</div>
<div class="line"><a id="l00824" name="l00824"></a><span class="lineno">  824</span>        <span class="keywordflow">else</span></div>
<div class="line"><a id="l00825" name="l00825"></a><span class="lineno">  825</span>        {</div>
<div class="line"><a id="l00826" name="l00826"></a><span class="lineno">  826</span>          err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a>;</div>
<div class="line"><a id="l00827" name="l00827"></a><span class="lineno">  827</span>          reply_with_rst = <span class="keyword">true</span>;</div>
<div class="line"><a id="l00828" name="l00828"></a><span class="lineno">  828</span>        }</div>
<div class="line"><a id="l00829" name="l00829"></a><span class="lineno">  829</span>      }</div>
<div class="line"><a id="l00830" name="l00830"></a><span class="lineno">  830</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Rst__packet.html">Rst_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00831" name="l00831"></a><span class="lineno">  831</span>      {</div>
<div class="line"><a id="l00832" name="l00832"></a><span class="lineno">  832</span>        <span class="comment">/* Shouldn&#39;t be common, but they are resetting connection for some reason.</span></div>
<div class="line"><a id="l00833" name="l00833"></a><span class="lineno">  833</span><span class="comment">         *</span></div>
<div class="line"><a id="l00834" name="l00834"></a><span class="lineno">  834</span><span class="comment">         * Close connection but don&#39;t reply to RST with RST (not useful; could cause endless</span></div>
<div class="line"><a id="l00835" name="l00835"></a><span class="lineno">  835</span><span class="comment">         * RSTing). */</span></div>
<div class="line"><a id="l00836" name="l00836"></a><span class="lineno">  836</span>        err_code = <a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4">error::Code::S_CONN_RESET_BY_OTHER_SIDE</a>;</div>
<div class="line"><a id="l00837" name="l00837"></a><span class="lineno">  837</span>      }</div>
<div class="line"><a id="l00838" name="l00838"></a><span class="lineno">  838</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Data__packet.html">Data_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00839" name="l00839"></a><span class="lineno">  839</span>      {</div>
<div class="line"><a id="l00840" name="l00840"></a><span class="lineno">  840</span>        <span class="comment">// Got DATA!  Great.</span></div>
<div class="line"><a id="l00841" name="l00841"></a><span class="lineno">  841</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a06e4cea2eefa1b06975864f09740c96b">handle_data_to_established</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>, sock,</div>
<div class="line"><a id="l00842" name="l00842"></a><span class="lineno">  842</span>                                   static_pointer_cast&lt;Data_packet&gt;(packet),</div>
<div class="line"><a id="l00843" name="l00843"></a><span class="lineno">  843</span>                                   <span class="keyword">false</span>); <span class="comment">// false &lt;=&gt; packet received in ESTABLISHED.</span></div>
<div class="line"><a id="l00844" name="l00844"></a><span class="lineno">  844</span>      }</div>
<div class="line"><a id="l00845" name="l00845"></a><span class="lineno">  845</span>      <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Ack__packet.html">Ack_packet</a>)) <span class="comment">// To ESTABLISHED state.</span></div>
<div class="line"><a id="l00846" name="l00846"></a><span class="lineno">  846</span>      {</div>
<div class="line"><a id="l00847" name="l00847"></a><span class="lineno">  847</span>        <span class="comment">// Got ACK!  Great.</span></div>
<div class="line"><a id="l00848" name="l00848"></a><span class="lineno">  848</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ab515b28350c43635728d6de0e37ccb94">handle_ack_to_established</a>(sock, static_pointer_cast&lt;const Ack_packet&gt;(packet));</div>
<div class="line"><a id="l00849" name="l00849"></a><span class="lineno">  849</span>      }</div>
<div class="line"><a id="l00850" name="l00850"></a><span class="lineno">  850</span>      <span class="keywordflow">else</span></div>
<div class="line"><a id="l00851" name="l00851"></a><span class="lineno">  851</span>      {</div>
<div class="line"><a id="l00852" name="l00852"></a><span class="lineno">  852</span>        assert(<span class="keyword">false</span>); <span class="comment">// We&#39;ve eliminated this already above.</span></div>
<div class="line"><a id="l00853" name="l00853"></a><span class="lineno">  853</span>      }</div>
<div class="line"><a id="l00854" name="l00854"></a><span class="lineno">  854</span>      <span class="keywordflow">break</span>;</div>
<div class="line"><a id="l00855" name="l00855"></a><span class="lineno">  855</span>    } <span class="comment">// case Peer_socket::Int_state::S_ESTABLISHED:</span></div>
<div class="line"><a id="l00856" name="l00856"></a><span class="lineno">  856</span>    <span class="keywordflow">case</span> <a class="code hl_enumvalue" href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa6abcbd1be8478aa03e76aec9c540e14f">Peer_socket::Int_state::S_CLOSED</a>:</div>
<div class="line"><a id="l00857" name="l00857"></a><span class="lineno">  857</span>      assert(<span class="keyword">false</span>); <span class="comment">// Can&#39;t be CLOSED, since it&#39;s in m_socks.</span></div>
<div class="line"><a id="l00858" name="l00858"></a><span class="lineno">  858</span>    } <span class="comment">// switch (state)</span></div>
<div class="line"><a id="l00859" name="l00859"></a><span class="lineno">  859</span> </div>
<div class="line"><a id="l00860" name="l00860"></a><span class="lineno">  860</span>    <span class="comment">// If above found we need to close this connection and/or send RST, do that.</span></div>
<div class="line"><a id="l00861" name="l00861"></a><span class="lineno">  861</span>    <span class="keywordflow">if</span> (err_code)</div>
<div class="line"><a id="l00862" name="l00862"></a><span class="lineno">  862</span>    {</div>
<div class="line"><a id="l00863" name="l00863"></a><span class="lineno">  863</span>      <span class="keywordflow">if</span> (reply_with_rst)</div>
<div class="line"><a id="l00864" name="l00864"></a><span class="lineno">  864</span>      {</div>
<div class="line"><a id="l00865" name="l00865"></a><span class="lineno">  865</span>        <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] targeted at [&quot;</span> &lt;&lt; sock &lt;&lt; <span class="stringliteral">&quot;] in &quot;</span></div>
<div class="line"><a id="l00866" name="l00866"></a><span class="lineno">  866</span>                         <span class="stringliteral">&quot;state [&quot;</span> &lt;&lt; state &lt;&lt; <span class="stringliteral">&quot;]; replying with RST.&quot;</span>);</div>
<div class="line"><a id="l00867" name="l00867"></a><span class="lineno">  867</span>        <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ad03aa88df3d1d3981454ee3356e868c1">async_sock_low_lvl_rst_send</a>(sock);</div>
<div class="line"><a id="l00868" name="l00868"></a><span class="lineno">  868</span>      }</div>
<div class="line"><a id="l00869" name="l00869"></a><span class="lineno">  869</span>      <span class="keywordflow">else</span></div>
<div class="line"><a id="l00870" name="l00870"></a><span class="lineno">  870</span>      {</div>
<div class="line"><a id="l00871" name="l00871"></a><span class="lineno">  871</span>        <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] targeted at [&quot;</span> &lt;&lt; sock &lt;&lt; <span class="stringliteral">&quot;] in &quot;</span></div>
<div class="line"><a id="l00872" name="l00872"></a><span class="lineno">  872</span>                         <span class="stringliteral">&quot;state [&quot;</span> &lt;&lt; state &lt;&lt; <span class="stringliteral">&quot;]; dropping without reply.&quot;</span>);</div>
<div class="line"><a id="l00873" name="l00873"></a><span class="lineno">  873</span>      }</div>
<div class="line"><a id="l00874" name="l00874"></a><span class="lineno">  874</span> </div>
<div class="line"><a id="l00875" name="l00875"></a><span class="lineno">  875</span>      <span class="comment">/* Close connection in our structures (inform user if necessary as well).  Pre-conditions</span></div>
<div class="line"><a id="l00876" name="l00876"></a><span class="lineno">  876</span><span class="comment">       * assumed by call: sock in m_socks and sock-&gt;state() == S_OPEN (yes, since sock is m_socks);</span></div>
<div class="line"><a id="l00877" name="l00877"></a><span class="lineno">  877</span><span class="comment">       * err_code contains the reason for the close (yes).  This will empty the Send and Receive</span></div>
<div class="line"><a id="l00878" name="l00878"></a><span class="lineno">  878</span><span class="comment">       * buffers (if applicable, i.e., only if state is ESTABLISHED or later).  That is OK,</span></div>
<div class="line"><a id="l00879" name="l00879"></a><span class="lineno">  879</span><span class="comment">       * because this is the abrupt type of close (error). */</span></div>
<div class="line"><a id="l00880" name="l00880"></a><span class="lineno">  880</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ade49e7bc7202a0adf33fec2d93d1b177">close_connection_immediately</a>(<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>, sock, err_code, <span class="keyword">true</span>);</div>
<div class="line"><a id="l00881" name="l00881"></a><span class="lineno">  881</span>      <span class="comment">/* ^-- defer_delta_check == true: because the only way to get to this method is from</span></div>
<div class="line"><a id="l00882" name="l00882"></a><span class="lineno">  882</span><span class="comment">       * async_low_lvl_recv(), which will perform event_set_all_check_delta(false) at the end of itself,</span></div>
<div class="line"><a id="l00883" name="l00883"></a><span class="lineno">  883</span><span class="comment">       * before the boost.asio handler exits.  See Node::m_sock_events doc header for details. */</span></div>
<div class="line"><a id="l00884" name="l00884"></a><span class="lineno">  884</span>    } <span class="comment">// if (error)</span></div>
<div class="line"><a id="l00885" name="l00885"></a><span class="lineno">  885</span> </div>
<div class="line"><a id="l00886" name="l00886"></a><span class="lineno">  886</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00887" name="l00887"></a><span class="lineno">  887</span>  } <span class="comment">// if (destination port is to a peer socket.)</span></div>
<div class="line"><a id="l00888" name="l00888"></a><span class="lineno">  888</span>  <span class="comment">// else destination port is not to a peer socket.</span></div>
<div class="line"><a id="l00889" name="l00889"></a><span class="lineno">  889</span> </div>
<div class="line"><a id="l00890" name="l00890"></a><span class="lineno">  890</span>  <span class="comment">// Check if destination port is to a server socket.</span></div>
<div class="line"><a id="l00891" name="l00891"></a><span class="lineno">  891</span>  Port_to_server_map::const_iterator serv_entry = <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aae28990628a86a07327f49973f2390df">m_servs</a>.find(flow_local_port);</div>
<div class="line"><a id="l00892" name="l00892"></a><span class="lineno">  892</span>  <span class="keywordflow">if</span> (serv_entry != <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#aae28990628a86a07327f49973f2390df">m_servs</a>.end())</div>
<div class="line"><a id="l00893" name="l00893"></a><span class="lineno">  893</span>  {</div>
<div class="line"><a id="l00894" name="l00894"></a><span class="lineno">  894</span>    <span class="comment">// Successful demultiplex to a server socket.</span></div>
<div class="line"><a id="l00895" name="l00895"></a><span class="lineno">  895</span>    <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Server_socket::Ptr</a> serv = serv_entry-&gt;second;</div>
<div class="line"><a id="l00896" name="l00896"></a><span class="lineno">  896</span> </div>
<div class="line"><a id="l00897" name="l00897"></a><span class="lineno">  897</span>    <span class="comment">/* Server socket can be in the following states:</span></div>
<div class="line"><a id="l00898" name="l00898"></a><span class="lineno">  898</span><span class="comment">     * - S_LISTENING: Waiting for SYNs.  Anything except a SYN is an error and yields an RST (except</span></div>
<div class="line"><a id="l00899" name="l00899"></a><span class="lineno">  899</span><span class="comment">     *   an RST does not yield an RST, as that&#39;s not useful and could lead to endless RSTing).</span></div>
<div class="line"><a id="l00900" name="l00900"></a><span class="lineno">  900</span><span class="comment">     * - S_CLOSING: No longer listening (in the process of being removed from Node).  Anything</span></div>
<div class="line"><a id="l00901" name="l00901"></a><span class="lineno">  901</span><span class="comment">     *   except an RST yields an RST (interepreted by other side as: connection refused [if SYN] or</span></div>
<div class="line"><a id="l00902" name="l00902"></a><span class="lineno">  902</span><span class="comment">     *   invalid message).</span></div>
<div class="line"><a id="l00903" name="l00903"></a><span class="lineno">  903</span><span class="comment">     *</span></div>
<div class="line"><a id="l00904" name="l00904"></a><span class="lineno">  904</span><span class="comment">     * S_CLOSED means it&#39;s not in m_serv, so that&#39;s not a possible state. */</span></div>
<div class="line"><a id="l00905" name="l00905"></a><span class="lineno">  905</span> </div>
<div class="line"><a id="l00906" name="l00906"></a><span class="lineno">  906</span>    <span class="comment">// state cannot change unless this thread W changes it, so no need to lock object across the below code.</span></div>
<div class="line"><a id="l00907" name="l00907"></a><span class="lineno">  907</span>    <span class="keyword">const</span> <a class="code hl_enumeration" href="classflow_1_1net__flow_1_1Server__socket.html#a8bc789b851677a47d7c0a1aa0c69a997">Server_socket::State</a> state = serv-&gt;state();</div>
<div class="line"><a id="l00908" name="l00908"></a><span class="lineno">  908</span>    <span class="keywordflow">if</span> ((state == <a class="code hl_enumvalue" href="classflow_1_1net__flow_1_1Server__socket.html#a8bc789b851677a47d7c0a1aa0c69a997aebae5ec546409cde4d74d99452d9cc8a">Server_socket::State::S_LISTENING</a>) &amp;&amp;</div>
<div class="line"><a id="l00909" name="l00909"></a><span class="lineno">  909</span>        (<span class="keyword">typeid</span>(packet_ref) == <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Syn__packet.html">Syn_packet</a>)))</div>
<div class="line"><a id="l00910" name="l00910"></a><span class="lineno">  910</span>    {</div>
<div class="line"><a id="l00911" name="l00911"></a><span class="lineno">  911</span>      <span class="keyword">auto</span> new_sock = <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aaaf5c3b5e6b9f9f1658b60907b36a498">handle_syn_to_listening_server</a>(serv,</div>
<div class="line"><a id="l00912" name="l00912"></a><span class="lineno">  912</span>                                                     static_pointer_cast&lt;const Syn_packet&gt;(packet),</div>
<div class="line"><a id="l00913" name="l00913"></a><span class="lineno">  913</span>                                                     low_lvl_remote_endpoint);</div>
<div class="line"><a id="l00914" name="l00914"></a><span class="lineno">  914</span>      <span class="keywordflow">if</span> (new_sock)</div>
<div class="line"><a id="l00915" name="l00915"></a><span class="lineno">  915</span>      {</div>
<div class="line"><a id="l00916" name="l00916"></a><span class="lineno">  916</span>        <span class="comment">/* Record packet size, type in stats of the socket, now that we know the latter.  It&#39;s kind of interesting,</span></div>
<div class="line"><a id="l00917" name="l00917"></a><span class="lineno">  917</span><span class="comment">         * as new_sock (as name implies) was just created based on the very packet we are registering here.</span></div>
<div class="line"><a id="l00918" name="l00918"></a><span class="lineno">  918</span><span class="comment">         * If it&#39;s a packet not corresponding to any Peer_socket, it won&#39;t be counted against any Peer_socket&#39;s stats</span></div>
<div class="line"><a id="l00919" name="l00919"></a><span class="lineno">  919</span><span class="comment">         * (but that is an unusual case; though there is a to-do [as of this writing] for counting things Node-wide</span></div>
<div class="line"><a id="l00920" name="l00920"></a><span class="lineno">  920</span><span class="comment">         * as well). */</span></div>
<div class="line"><a id="l00921" name="l00921"></a><span class="lineno">  921</span>        new_sock-&gt;m_rcv_stats.low_lvl_packet(<span class="keyword">typeid</span>(packet_ref), packet_data_size);</div>
<div class="line"><a id="l00922" name="l00922"></a><span class="lineno">  922</span>      }</div>
<div class="line"><a id="l00923" name="l00923"></a><span class="lineno">  923</span>      <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00924" name="l00924"></a><span class="lineno">  924</span>    }</div>
<div class="line"><a id="l00925" name="l00925"></a><span class="lineno">  925</span>    <span class="comment">// else</span></div>
<div class="line"><a id="l00926" name="l00926"></a><span class="lineno">  926</span>    <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) != <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Rst__packet.html">Rst_packet</a>))</div>
<div class="line"><a id="l00927" name="l00927"></a><span class="lineno">  927</span>    {</div>
<div class="line"><a id="l00928" name="l00928"></a><span class="lineno">  928</span>      <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] from &quot;</span></div>
<div class="line"><a id="l00929" name="l00929"></a><span class="lineno">  929</span>                       <span class="stringliteral">&quot;[UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;] targeted at state [&quot;</span> &lt;&lt; state &lt;&lt; <span class="stringliteral">&quot;] &quot;</span></div>
<div class="line"><a id="l00930" name="l00930"></a><span class="lineno">  930</span>                       <span class="stringliteral">&quot;server port [&quot;</span> &lt;&lt; flow_local_port &lt;&lt; <span class="stringliteral">&quot;]; replying with RST.&quot;</span>);</div>
<div class="line"><a id="l00931" name="l00931"></a><span class="lineno">  931</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a74a6a82a1390a76e985593969fb47184">async_no_sock_low_lvl_rst_send</a>(packet, low_lvl_remote_endpoint);</div>
<div class="line"><a id="l00932" name="l00932"></a><span class="lineno">  932</span>    }</div>
<div class="line"><a id="l00933" name="l00933"></a><span class="lineno">  933</span>    <span class="keywordflow">else</span></div>
<div class="line"><a id="l00934" name="l00934"></a><span class="lineno">  934</span>    {</div>
<div class="line"><a id="l00935" name="l00935"></a><span class="lineno">  935</span>      <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] from &quot;</span></div>
<div class="line"><a id="l00936" name="l00936"></a><span class="lineno">  936</span>                       <span class="stringliteral">&quot;[UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;] targeted at state [&quot;</span> &lt;&lt; state &lt;&lt; <span class="stringliteral">&quot;] &quot;</span></div>
<div class="line"><a id="l00937" name="l00937"></a><span class="lineno">  937</span>                       <span class="stringliteral">&quot;server port [&quot;</span> &lt;&lt; flow_local_port &lt;&lt; <span class="stringliteral">&quot;]; dropping without reply.&quot;</span>);</div>
<div class="line"><a id="l00938" name="l00938"></a><span class="lineno">  938</span>    }</div>
<div class="line"><a id="l00939" name="l00939"></a><span class="lineno">  939</span>    <span class="keywordflow">return</span>;</div>
<div class="line"><a id="l00940" name="l00940"></a><span class="lineno">  940</span>  } <span class="comment">// if (demuxed to server socket)</span></div>
<div class="line"><a id="l00941" name="l00941"></a><span class="lineno">  941</span>  <span class="comment">// else destination port is not to a peer-to-peer socket or a server socket.</span></div>
<div class="line"><a id="l00942" name="l00942"></a><span class="lineno">  942</span> </div>
<div class="line"><a id="l00943" name="l00943"></a><span class="lineno">  943</span>  <span class="comment">// Handle NOT_A_SOCKET state.</span></div>
<div class="line"><a id="l00944" name="l00944"></a><span class="lineno">  944</span> </div>
<div class="line"><a id="l00945" name="l00945"></a><span class="lineno">  945</span>  <span class="comment">/* Destination socket is not a socket.  In this degenerate state any incoming packets are</span></div>
<div class="line"><a id="l00946" name="l00946"></a><span class="lineno">  946</span><span class="comment">   * rejected.  Help the other side by issuing an RST.  In particular they may be trying to SYN a</span></div>
<div class="line"><a id="l00947" name="l00947"></a><span class="lineno">  947</span><span class="comment">   * non-listening socket, for example, and the RST will prevent them from waiting around before</span></div>
<div class="line"><a id="l00948" name="l00948"></a><span class="lineno">  948</span><span class="comment">   * giving up.</span></div>
<div class="line"><a id="l00949" name="l00949"></a><span class="lineno">  949</span><span class="comment">   *</span></div>
<div class="line"><a id="l00950" name="l00950"></a><span class="lineno">  950</span><span class="comment">   * Exception: Don&#39;t issue an RST to an RST, as that&#39;s not useful (and could result in endless</span></div>
<div class="line"><a id="l00951" name="l00951"></a><span class="lineno">  951</span><span class="comment">   * RSTing, maybe). */</span></div>
<div class="line"><a id="l00952" name="l00952"></a><span class="lineno">  952</span>  <span class="keywordflow">if</span> (<span class="keyword">typeid</span>(packet_ref) != <span class="keyword">typeid</span>(<a class="code hl_struct" href="structflow_1_1net__flow_1_1Rst__packet.html">Rst_packet</a>))</div>
<div class="line"><a id="l00953" name="l00953"></a><span class="lineno">  953</span>  {</div>
<div class="line"><a id="l00954" name="l00954"></a><span class="lineno">  954</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet from [UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;] specified state [NOT_A_SOCKET] &quot;</span></div>
<div class="line"><a id="l00955" name="l00955"></a><span class="lineno">  955</span>                     <span class="stringliteral">&quot;port [&quot;</span> &lt;&lt; flow_local_port &lt;&lt; <span class="stringliteral">&quot;]; meaning no such socket known; replying with RST.&quot;</span>);</div>
<div class="line"><a id="l00956" name="l00956"></a><span class="lineno">  956</span>    <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a74a6a82a1390a76e985593969fb47184">async_no_sock_low_lvl_rst_send</a>(packet, low_lvl_remote_endpoint);</div>
<div class="line"><a id="l00957" name="l00957"></a><span class="lineno">  957</span>  }</div>
<div class="line"><a id="l00958" name="l00958"></a><span class="lineno">  958</span>  <span class="keywordflow">else</span></div>
<div class="line"><a id="l00959" name="l00959"></a><span class="lineno">  959</span>  {</div>
<div class="line"><a id="l00960" name="l00960"></a><span class="lineno">  960</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;Packet of type [&quot;</span> &lt;&lt; packet-&gt;m_type_ostream_manip &lt;&lt; <span class="stringliteral">&quot;] from &quot;</span></div>
<div class="line"><a id="l00961" name="l00961"></a><span class="lineno">  961</span>                     <span class="stringliteral">&quot;[UDP &quot;</span> &lt;&lt; low_lvl_remote_endpoint &lt;&lt; <span class="stringliteral">&quot;] specified state [NOT_A_SOCKET] &quot;</span></div>
<div class="line"><a id="l00962" name="l00962"></a><span class="lineno">  962</span>                     <span class="stringliteral">&quot;port [&quot;</span> &lt;&lt; flow_local_port &lt;&lt; <span class="stringliteral">&quot;]; meaning no such socket known; dropping without reply.&quot;</span>);</div>
<div class="line"><a id="l00963" name="l00963"></a><span class="lineno">  963</span>  }</div>
<div class="line"><a id="l00964" name="l00964"></a><span class="lineno">  964</span>} <span class="comment">// Node::handle_incoming()</span></div>
<div class="line"><a id="l00965" name="l00965"></a><span class="lineno">  965</span><span class="comment"></span> </div>
<div class="line"><a id="l00966" name="l00966"></a><span class="lineno">  966</span><span class="comment">/// @cond</span></div>
<div class="line"><a id="l00967" name="l00967"></a><span class="lineno">  967</span><span class="comment"></span><span class="comment">/* -^- Doxygen, please ignore the following.  (Don&#39;t want docs generated for temp macro; this is more maintainable</span></div>
<div class="line"><a id="l00968" name="l00968"></a><span class="lineno">  968</span><span class="comment"> * than specifying the macro name to omit it, in Doxygen-config EXCLUDE_SYMBOLS.) */</span></div>
<div class="line"><a id="l00969" name="l00969"></a><span class="lineno">  969</span> </div>
<div class="line"><a id="l00970" name="l00970"></a><span class="lineno">  970</span><span class="comment">/* Normaly I try to avoid macro cleverness, but in this case to get a nice printout we need the</span></div>
<div class="line"><a id="l00971" name="l00971"></a><span class="lineno">  971</span><span class="comment"> * # technique, and also this eliminates quite a bit of repetition.  So let&#39;s.... */</span></div>
<div class="line"><a id="l00972" name="l00972"></a><span class="lineno">  972</span><span class="preprocessor">#define VALIDATE_STATIC_OPTION(ARG_opt) \</span></div>
<div class="line"><a id="l00973" name="l00973"></a><span class="lineno">  973</span><span class="preprocessor">  validate_static_option(opts.ARG_opt, m_opts.ARG_opt, #ARG_opt, err_code)</span></div>
<div class="line"><a id="l00974" name="l00974"></a><span class="lineno">  974</span><span class="preprocessor">#define VALIDATE_CHECK(ARG_check) \</span></div>
<div class="line"><a id="l00975" name="l00975"></a><span class="lineno">  975</span><span class="preprocessor">  validate_option_check(ARG_check, #ARG_check, err_code)</span></div>
<div class="line"><a id="l00976" name="l00976"></a><span class="lineno">  976</span> </div>
<div class="line"><a id="l00977" name="l00977"></a><span class="lineno">  977</span><span class="comment">// -v- Doxygen, please stop ignoring.</span><span class="comment"></span></div>
<div class="line"><a id="l00978" name="l00978"></a><span class="lineno">  978</span><span class="comment">/// @endcond</span></div>
<div class="line"><a id="l00979" name="l00979"></a><span class="lineno">  979</span><span class="comment"></span> </div>
<div class="line"><a id="l00980" name="l00980"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#ab2595f47710ddb06cfb22b6710b7286e">  980</a></span><span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ab2595f47710ddb06cfb22b6710b7286e">Node::validate_options</a>(<span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; opts, <span class="keywordtype">bool</span> init, <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>* err_code)<span class="keyword"> const</span></div>
<div class="line"><a id="l00981" name="l00981"></a><span class="lineno">  981</span><span class="keyword"></span>{</div>
<div class="line"><a id="l00982" name="l00982"></a><span class="lineno">  982</span>  <span class="comment">// Note: Can&#39;t use FLOW_ERROR_EXEC_AND_THROW_ON_ERROR() as return is a reference.  @todo Look into solution?</span></div>
<div class="line"><a id="l00983" name="l00983"></a><span class="lineno">  983</span>  <span class="keywordflow">if</span> (!err_code) <span class="comment">// Call the non-null err_code version of ourselves, and throw exception on error.</span></div>
<div class="line"><a id="l00984" name="l00984"></a><span class="lineno">  984</span>  {</div>
<div class="line"><a id="l00985" name="l00985"></a><span class="lineno">  985</span>    <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a> our_err_code;</div>
<div class="line"><a id="l00986" name="l00986"></a><span class="lineno">  986</span>    <span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; result = <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ab2595f47710ddb06cfb22b6710b7286e">validate_options</a>(opts, init, &amp;our_err_code);</div>
<div class="line"><a id="l00987" name="l00987"></a><span class="lineno">  987</span>    <span class="keywordflow">if</span> (our_err_code)</div>
<div class="line"><a id="l00988" name="l00988"></a><span class="lineno">  988</span>    {</div>
<div class="line"><a id="l00989" name="l00989"></a><span class="lineno">  989</span>      <span class="keywordflow">throw</span> <a class="code hl_class" href="classflow_1_1error_1_1Runtime__error.html">flow::error::Runtime_error</a>(our_err_code, <a class="code hl_define" href="util__fwd_8hpp.html#a0cc4c82ac54e53b7a8a2431b66ff30df">FLOW_UTIL_WHERE_AM_I_STR</a>());</div>
<div class="line"><a id="l00990" name="l00990"></a><span class="lineno">  990</span>    }</div>
<div class="line"><a id="l00991" name="l00991"></a><span class="lineno">  991</span>    <span class="keywordflow">return</span> result;</div>
<div class="line"><a id="l00992" name="l00992"></a><span class="lineno">  992</span>  }</div>
<div class="line"><a id="l00993" name="l00993"></a><span class="lineno">  993</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l00994" name="l00994"></a><span class="lineno">  994</span> </div>
<div class="line"><a id="l00995" name="l00995"></a><span class="lineno">  995</span>  <span class="comment">/* We are to validate the given set of global option values.  If init, then the context is that an</span></div>
<div class="line"><a id="l00996" name="l00996"></a><span class="lineno">  996</span><span class="comment">   * already-running Node is being called with set_options(), i.e. user is modifying options for an</span></div>
<div class="line"><a id="l00997" name="l00997"></a><span class="lineno">  997</span><span class="comment">   * existing Node.  In that case we must ensure that no static (unchangeable) option&#39;s value</span></div>
<div class="line"><a id="l00998" name="l00998"></a><span class="lineno">  998</span><span class="comment">   * would be changed by this.</span></div>
<div class="line"><a id="l00999" name="l00999"></a><span class="lineno">  999</span><span class="comment">   *</span></div>
<div class="line"><a id="l01000" name="l01000"></a><span class="lineno"> 1000</span><span class="comment">   * If not init, then we&#39;re validating the options set given to us in Node constructor.  So in</span></div>
<div class="line"><a id="l01001" name="l01001"></a><span class="lineno"> 1001</span><span class="comment">   * that case that static option check is to be skipped, since there are no existing option values</span></div>
<div class="line"><a id="l01002" name="l01002"></a><span class="lineno"> 1002</span><span class="comment">   * to change.</span></div>
<div class="line"><a id="l01003" name="l01003"></a><span class="lineno"> 1003</span><span class="comment">   *</span></div>
<div class="line"><a id="l01004" name="l01004"></a><span class="lineno"> 1004</span><span class="comment">   * Finally, we must check for individual integrity of the specified values (including consistency</span></div>
<div class="line"><a id="l01005" name="l01005"></a><span class="lineno"> 1005</span><span class="comment">   * with other option values). */</span></div>
<div class="line"><a id="l01006" name="l01006"></a><span class="lineno"> 1006</span> </div>
<div class="line"><a id="l01007" name="l01007"></a><span class="lineno"> 1007</span>  <span class="comment">// We are in thread U != W or in thread W.</span></div>
<div class="line"><a id="l01008" name="l01008"></a><span class="lineno"> 1008</span> </div>
<div class="line"><a id="l01009" name="l01009"></a><span class="lineno"> 1009</span>  <span class="keywordflow">if</span> (!init)</div>
<div class="line"><a id="l01010" name="l01010"></a><span class="lineno"> 1010</span>  {</div>
<div class="line"><a id="l01011" name="l01011"></a><span class="lineno"> 1011</span>    <span class="comment">/* As explained above, they&#39;re trying to change an existing Node&#39;s option values.  Ensure all</span></div>
<div class="line"><a id="l01012" name="l01012"></a><span class="lineno"> 1012</span><span class="comment">     * the static options&#39; values are the same in opts and m_opts. */</span></div>
<div class="line"><a id="l01013" name="l01013"></a><span class="lineno"> 1013</span> </div>
<div class="line"><a id="l01014" name="l01014"></a><span class="lineno"> 1014</span>    <span class="comment">// Explicitly documented pre-condition is that m_opts is already locked if necessary.  So don&#39;t lock.</span></div>
<div class="line"><a id="l01015" name="l01015"></a><span class="lineno"> 1015</span> </div>
<div class="line"><a id="l01016" name="l01016"></a><span class="lineno"> 1016</span>    <span class="keyword">const</span> <span class="keywordtype">bool</span> static_ok</div>
<div class="line"><a id="l01017" name="l01017"></a><span class="lineno"> 1017</span>      = VALIDATE_STATIC_OPTION(m_st_capture_interrupt_signals_internally) &amp;&amp;</div>
<div class="line"><a id="l01018" name="l01018"></a><span class="lineno"> 1018</span>        VALIDATE_STATIC_OPTION(m_st_low_lvl_max_buf_size) &amp;&amp;</div>
<div class="line"><a id="l01019" name="l01019"></a><span class="lineno"> 1019</span>        VALIDATE_STATIC_OPTION(m_st_timer_min_period);</div>
<div class="line"><a id="l01020" name="l01020"></a><span class="lineno"> 1020</span> </div>
<div class="line"><a id="l01021" name="l01021"></a><span class="lineno"> 1021</span>    <span class="keywordflow">if</span> (!static_ok)</div>
<div class="line"><a id="l01022" name="l01022"></a><span class="lineno"> 1022</span>    {</div>
<div class="line"><a id="l01023" name="l01023"></a><span class="lineno"> 1023</span>      <span class="comment">// validate_static_option() has set *err_code.</span></div>
<div class="line"><a id="l01024" name="l01024"></a><span class="lineno"> 1024</span>      <span class="keywordflow">return</span> opts;</div>
<div class="line"><a id="l01025" name="l01025"></a><span class="lineno"> 1025</span>    }</div>
<div class="line"><a id="l01026" name="l01026"></a><span class="lineno"> 1026</span>    <span class="comment">// else</span></div>
<div class="line"><a id="l01027" name="l01027"></a><span class="lineno"> 1027</span>  } <span class="comment">// if (!init)</span></div>
<div class="line"><a id="l01028" name="l01028"></a><span class="lineno"> 1028</span> </div>
<div class="line"><a id="l01029" name="l01029"></a><span class="lineno"> 1029</span>  <span class="comment">// Now sanity-check the values themselves.  @todo Comment and reconsider these?</span></div>
<div class="line"><a id="l01030" name="l01030"></a><span class="lineno"> 1030</span> </div>
<div class="line"><a id="l01031" name="l01031"></a><span class="lineno"> 1031</span>  <span class="keyword">const</span> <span class="keywordtype">bool</span> checks_ok</div>
<div class="line"><a id="l01032" name="l01032"></a><span class="lineno"> 1032</span>    = VALIDATE_CHECK(opts.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#a78baaf1a911c8d490a13278422307e8a">m_st_low_lvl_max_buf_size</a> &gt;= 128 * 1024) &amp;&amp;</div>
<div class="line"><a id="l01033" name="l01033"></a><span class="lineno"> 1033</span>      VALIDATE_CHECK(opts.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#abef8889be34024b07eff3211a3213d5f">m_st_timer_min_period</a>.count() &gt;= 0) &amp;&amp;</div>
<div class="line"><a id="l01034" name="l01034"></a><span class="lineno"> 1034</span>      VALIDATE_CHECK(opts.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#a88c732d10914f406cc43a2c20cc800c6">m_dyn_low_lvl_max_packet_size</a> &gt;= 512);</div>
<div class="line"><a id="l01035" name="l01035"></a><span class="lineno"> 1035</span> </div>
<div class="line"><a id="l01036" name="l01036"></a><span class="lineno"> 1036</span>  <span class="keywordflow">if</span> (!checks_ok)</div>
<div class="line"><a id="l01037" name="l01037"></a><span class="lineno"> 1037</span>  {</div>
<div class="line"><a id="l01038" name="l01038"></a><span class="lineno"> 1038</span>    <span class="comment">// On error, validate_option_check() has set *err_code.</span></div>
<div class="line"><a id="l01039" name="l01039"></a><span class="lineno"> 1039</span>    <span class="keywordflow">return</span> opts;</div>
<div class="line"><a id="l01040" name="l01040"></a><span class="lineno"> 1040</span>  }</div>
<div class="line"><a id="l01041" name="l01041"></a><span class="lineno"> 1041</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l01042" name="l01042"></a><span class="lineno"> 1042</span> </div>
<div class="line"><a id="l01043" name="l01043"></a><span class="lineno"> 1043</span>  <span class="comment">/* The above validated only global options.  Now verify that the per-socket template options (that</span></div>
<div class="line"><a id="l01044" name="l01044"></a><span class="lineno"> 1044</span><span class="comment">   * will be used to generate child Peer_sockets) are also valid. */</span></div>
<div class="line"><a id="l01045" name="l01045"></a><span class="lineno"> 1045</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a446ee7115c70cbcd48e3897d32fc0276">sock_validate_options</a>(opts.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#a71b56a75a4b6dba57daeef79b0b880f7">m_dyn_sock_opts</a>, 0, err_code); <span class="comment">// Will not throw.  Will set *err_code if needed.</span></div>
<div class="line"><a id="l01046" name="l01046"></a><span class="lineno"> 1046</span>  <span class="comment">// On error, that set *err_code.</span></div>
<div class="line"><a id="l01047" name="l01047"></a><span class="lineno"> 1047</span> </div>
<div class="line"><a id="l01048" name="l01048"></a><span class="lineno"> 1048</span>  <span class="keywordflow">return</span> opts;</div>
<div class="line"><a id="l01049" name="l01049"></a><span class="lineno"> 1049</span> </div>
<div class="line"><a id="l01050" name="l01050"></a><span class="lineno"> 1050</span><span class="preprocessor">#undef VALIDATE_CHECK</span></div>
<div class="line"><a id="l01051" name="l01051"></a><span class="lineno"> 1051</span><span class="preprocessor">#undef VALIDATE_STATIC_OPTION</span></div>
<div class="line"><a id="l01052" name="l01052"></a><span class="lineno"> 1052</span>} <span class="comment">// Node::validate_options()</span></div>
<div class="line"><a id="l01053" name="l01053"></a><span class="lineno"> 1053</span> </div>
<div class="line"><a id="l01054" name="l01054"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a2779cc2429651696df1bca8de73534f3"> 1054</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a2779cc2429651696df1bca8de73534f3">Node::set_options</a>(<span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a>&amp; opts, <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>* err_code)</div>
<div class="line"><a id="l01055" name="l01055"></a><span class="lineno"> 1055</span>{</div>
<div class="line"><a id="l01056" name="l01056"></a><span class="lineno"> 1056</span>  <a class="code hl_define" href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR</a>(<span class="keywordtype">bool</span>, <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a2779cc2429651696df1bca8de73534f3">set_options</a>, opts, _1);</div>
<div class="line"><a id="l01057" name="l01057"></a><span class="lineno"> 1057</span>  <span class="comment">// ^-- Call ourselves and return if err_code is null.  If got to present line, err_code is not null.</span></div>
<div class="line"><a id="l01058" name="l01058"></a><span class="lineno"> 1058</span> </div>
<div class="line"><a id="l01059" name="l01059"></a><span class="lineno"> 1059</span>  <span class="comment">// We are in thread U != W.</span></div>
<div class="line"><a id="l01060" name="l01060"></a><span class="lineno"> 1060</span> </div>
<div class="line"><a id="l01061" name="l01061"></a><span class="lineno"> 1061</span>  <span class="keywordflow">if</span> (!<a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aae148cec361b59237996a4b30c6624b5">running</a>())</div>
<div class="line"><a id="l01062" name="l01062"></a><span class="lineno"> 1062</span>  {</div>
<div class="line"><a id="l01063" name="l01063"></a><span class="lineno"> 1063</span>    <a class="code hl_define" href="error_2error_8hpp.html#ab6b8ed79012c994cfc381e0b92c066fd">FLOW_ERROR_EMIT_ERROR</a>(<a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e">error::Code::S_NODE_NOT_RUNNING</a>);</div>
<div class="line"><a id="l01064" name="l01064"></a><span class="lineno"> 1064</span>    <span class="keywordflow">return</span> <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Peer_socket::Ptr</a>().get();</div>
<div class="line"><a id="l01065" name="l01065"></a><span class="lineno"> 1065</span>  }</div>
<div class="line"><a id="l01066" name="l01066"></a><span class="lineno"> 1066</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l01067" name="l01067"></a><span class="lineno"> 1067</span> </div>
<div class="line"><a id="l01068" name="l01068"></a><span class="lineno"> 1068</span>  <span class="comment">/* We just want to replace m_opts with a copy of opts.  First validate opts (including with</span></div>
<div class="line"><a id="l01069" name="l01069"></a><span class="lineno"> 1069</span><span class="comment">   * respect to m_opts, and also check for invalid values and such), then copy it over. */</span></div>
<div class="line"><a id="l01070" name="l01070"></a><span class="lineno"> 1070</span> </div>
<div class="line"><a id="l01071" name="l01071"></a><span class="lineno"> 1071</span>  <span class="comment">// Log new options values.  A bit computationally expensive so just use TRACE for now.  @todo Reconsider?</span></div>
<div class="line"><a id="l01072" name="l01072"></a><span class="lineno"> 1072</span>  <a class="code hl_define" href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a>(<span class="stringliteral">&quot;\n\n&quot;</span> &lt;&lt; opts);</div>
<div class="line"><a id="l01073" name="l01073"></a><span class="lineno"> 1073</span> </div>
<div class="line"><a id="l01074" name="l01074"></a><span class="lineno"> 1074</span>  <span class="comment">// Will be writing if all goes well, so must acquire exclusive ownership of m_opts.</span></div>
<div class="line"><a id="l01075" name="l01075"></a><span class="lineno"> 1075</span>  <a class="code hl_typedef" href="classflow_1_1net__flow_1_1Node.html#a97c8679c70ac9c7dda394fdf335aaed7">Options_lock</a> lock(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a449ef757abee4c5d12f8fc62a5ca66b4">m_opts_mutex</a>);</div>
<div class="line"><a id="l01076" name="l01076"></a><span class="lineno"> 1076</span> </div>
<div class="line"><a id="l01077" name="l01077"></a><span class="lineno"> 1077</span>  <span class="comment">/* Validate the new option set (including ensuring they&#39;re not changing static options&#39; values).</span></div>
<div class="line"><a id="l01078" name="l01078"></a><span class="lineno"> 1078</span><span class="comment">   * Note that an explicit pre-condition of this method is that m_opts_mutex is locked if needed,</span></div>
<div class="line"><a id="l01079" name="l01079"></a><span class="lineno"> 1079</span><span class="comment">   * hence the above locking statement is not below this call. */</span></div>
<div class="line"><a id="l01080" name="l01080"></a><span class="lineno"> 1080</span>  <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#ab2595f47710ddb06cfb22b6710b7286e">validate_options</a>(opts, <span class="keyword">false</span>, err_code);</div>
<div class="line"><a id="l01081" name="l01081"></a><span class="lineno"> 1081</span>  <span class="keywordflow">if</span> (*err_code)</div>
<div class="line"><a id="l01082" name="l01082"></a><span class="lineno"> 1082</span>  {</div>
<div class="line"><a id="l01083" name="l01083"></a><span class="lineno"> 1083</span>    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l01084" name="l01084"></a><span class="lineno"> 1084</span>  }</div>
<div class="line"><a id="l01085" name="l01085"></a><span class="lineno"> 1085</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l01086" name="l01086"></a><span class="lineno"> 1086</span> </div>
<div class="line"><a id="l01087" name="l01087"></a><span class="lineno"> 1087</span>  <span class="comment">// Boo-ya.</span></div>
<div class="line"><a id="l01088" name="l01088"></a><span class="lineno"> 1088</span>  <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a> = opts;</div>
<div class="line"><a id="l01089" name="l01089"></a><span class="lineno"> 1089</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l01090" name="l01090"></a><span class="lineno"> 1090</span>} <span class="comment">// Node::set_options()</span></div>
<div class="line"><a id="l01091" name="l01091"></a><span class="lineno"> 1091</span> </div>
<div class="line"><a id="l01092" name="l01092"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a9511f3ba50d19f2c32a8de94f0a306e8"> 1092</a></span><span class="keywordtype">bool</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a9511f3ba50d19f2c32a8de94f0a306e8">Node::validate_option_check</a>(<span class="keywordtype">bool</span> check, <span class="keyword">const</span> std::string&amp; check_str,</div>
<div class="line"><a id="l01093" name="l01093"></a><span class="lineno"> 1093</span>                                 <a class="code hl_typedef" href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">Error_code</a>* err_code)<span class="keyword"> const</span></div>
<div class="line"><a id="l01094" name="l01094"></a><span class="lineno"> 1094</span><span class="keyword"></span>{</div>
<div class="line"><a id="l01095" name="l01095"></a><span class="lineno"> 1095</span>  <span class="keywordflow">if</span> (!check)</div>
<div class="line"><a id="l01096" name="l01096"></a><span class="lineno"> 1096</span>  {</div>
<div class="line"><a id="l01097" name="l01097"></a><span class="lineno"> 1097</span>    <a class="code hl_define" href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a>(<span class="stringliteral">&quot;When changing options, check [&quot;</span> &lt;&lt; check_str &lt;&lt; <span class="stringliteral">&quot;] is false.  &quot;</span></div>
<div class="line"><a id="l01098" name="l01098"></a><span class="lineno"> 1098</span>                     <span class="stringliteral">&quot;Ignoring entire option set.&quot;</span>);</div>
<div class="line"><a id="l01099" name="l01099"></a><span class="lineno"> 1099</span>    <a class="code hl_define" href="error_2error_8hpp.html#ab6b8ed79012c994cfc381e0b92c066fd">FLOW_ERROR_EMIT_ERROR</a>(<a class="code hl_enumvalue" href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450">error::Code::S_OPTION_CHECK_FAILED</a>);</div>
<div class="line"><a id="l01100" name="l01100"></a><span class="lineno"> 1100</span>    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a id="l01101" name="l01101"></a><span class="lineno"> 1101</span>  }</div>
<div class="line"><a id="l01102" name="l01102"></a><span class="lineno"> 1102</span>  <span class="comment">// else</span></div>
<div class="line"><a id="l01103" name="l01103"></a><span class="lineno"> 1103</span>  <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a id="l01104" name="l01104"></a><span class="lineno"> 1104</span>}</div>
<div class="line"><a id="l01105" name="l01105"></a><span class="lineno"> 1105</span> </div>
<div class="line"><a id="l01106" name="l01106"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a159b9c2b9a8a969f5e3715341c433aec"> 1106</a></span><a class="code hl_struct" href="structflow_1_1net__flow_1_1Node__options.html">Node_options</a> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a159b9c2b9a8a969f5e3715341c433aec">Node::options</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l01107" name="l01107"></a><span class="lineno"> 1107</span><span class="keyword"></span>{</div>
<div class="line"><a id="l01108" name="l01108"></a><span class="lineno"> 1108</span>  <span class="keywordflow">return</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a43c42121d48a55a43a48e3a84bd10595">opt</a>(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a>); <span class="comment">// Lock, copy entire struct, unlock, return copy.</span></div>
<div class="line"><a id="l01109" name="l01109"></a><span class="lineno"> 1109</span>}</div>
<div class="line"><a id="l01110" name="l01110"></a><span class="lineno"> 1110</span> </div>
<div class="line"><a id="l01111" name="l01111"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577"> 1111</a></span><span class="keywordtype">size_t</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">Node::max_block_size</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l01112" name="l01112"></a><span class="lineno"> 1112</span><span class="keyword"></span>{</div>
<div class="line"><a id="l01113" name="l01113"></a><span class="lineno"> 1113</span>  <span class="keywordflow">return</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a43c42121d48a55a43a48e3a84bd10595">opt</a>(<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">m_opts</a>.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node__options.html#a71b56a75a4b6dba57daeef79b0b880f7">m_dyn_sock_opts</a>.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Peer__socket__options.html#aeaaf832a38a5e334789e81e214686ea7">m_st_max_block_size</a>);</div>
<div class="line"><a id="l01114" name="l01114"></a><span class="lineno"> 1114</span>}</div>
<div class="line"><a id="l01115" name="l01115"></a><span class="lineno"> 1115</span> </div>
<div class="line"><a id="l01116" name="l01116"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb"> 1116</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb">Node::perform_regular_infrequent_tasks</a>(<span class="keywordtype">bool</span> reschedule)</div>
<div class="line"><a id="l01117" name="l01117"></a><span class="lineno"> 1117</span>{</div>
<div class="line"><a id="l01118" name="l01118"></a><span class="lineno"> 1118</span>  <span class="keyword">using </span><a class="code hl_function" href="namespaceflow_1_1util.html#a74d4a66fb00055be4e1bd6ee98e04667">util::schedule_task_from_now</a>;</div>
<div class="line"><a id="l01119" name="l01119"></a><span class="lineno"> 1119</span> </div>
<div class="line"><a id="l01120" name="l01120"></a><span class="lineno"> 1120</span>  <span class="comment">// We are in thread W.</span></div>
<div class="line"><a id="l01121" name="l01121"></a><span class="lineno"> 1121</span> </div>
<div class="line"><a id="l01122" name="l01122"></a><span class="lineno"> 1122</span>  <span class="comment">// The frequency is low enough to where we can use detailed logging with impunity in this method.</span></div>
<div class="line"><a id="l01123" name="l01123"></a><span class="lineno"> 1123</span> </div>
<div class="line"><a id="l01124" name="l01124"></a><span class="lineno"> 1124</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;[=== Periodic state logging. ===&quot;</span>);</div>
<div class="line"><a id="l01125" name="l01125"></a><span class="lineno"> 1125</span> </div>
<div class="line"><a id="l01126" name="l01126"></a><span class="lineno"> 1126</span>  <span class="comment">// Just log the stats for each Peer_socket.  @todo Add Server_socket, Event_set when they have stats; global state.</span></div>
<div class="line"><a id="l01127" name="l01127"></a><span class="lineno"> 1127</span> </div>
<div class="line"><a id="l01128" name="l01128"></a><span class="lineno"> 1128</span>  <span class="keywordflow">for</span> (<span class="keyword">const</span> <span class="keyword">auto</span>&amp; id_and_sock : <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">m_socks</a>)</div>
<div class="line"><a id="l01129" name="l01129"></a><span class="lineno"> 1129</span>  {</div>
<div class="line"><a id="l01130" name="l01130"></a><span class="lineno"> 1130</span>    <a class="code hl_typedef" href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">Peer_socket::Ptr</a> sock = id_and_sock.second;</div>
<div class="line"><a id="l01131" name="l01131"></a><span class="lineno"> 1131</span>    <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a755c329b9e0f2b8edb2e5b900bd2a337">sock_log_detail</a>(sock);</div>
<div class="line"><a id="l01132" name="l01132"></a><span class="lineno"> 1132</span>  }</div>
<div class="line"><a id="l01133" name="l01133"></a><span class="lineno"> 1133</span> </div>
<div class="line"><a id="l01134" name="l01134"></a><span class="lineno"> 1134</span>  <a class="code hl_define" href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a>(<span class="stringliteral">&quot;=== Periodic state logging. ===]&quot;</span>);</div>
<div class="line"><a id="l01135" name="l01135"></a><span class="lineno"> 1135</span> </div>
<div class="line"><a id="l01136" name="l01136"></a><span class="lineno"> 1136</span>  <span class="keywordflow">if</span> (reschedule)</div>
<div class="line"><a id="l01137" name="l01137"></a><span class="lineno"> 1137</span>  {</div>
<div class="line"><a id="l01138" name="l01138"></a><span class="lineno"> 1138</span>    <a class="code hl_function" href="namespaceflow_1_1util.html#a74d4a66fb00055be4e1bd6ee98e04667">schedule_task_from_now</a>(<a class="code hl_function" href="classflow_1_1log_1_1Log__context.html#af4db395042b065b00398cd59845dcb4d">get_logger</a>(), <a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#a2f97b363281b79ef4f399789442c84de">S_REGULAR_INFREQUENT_TASKS_PERIOD</a>, <span class="keyword">true</span>, &amp;<a class="code hl_variable" href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">m_task_engine</a>,</div>
<div class="line"><a id="l01139" name="l01139"></a><span class="lineno"> 1139</span>                           [<span class="keyword">this</span>](<span class="keywordtype">bool</span>)</div>
<div class="line"><a id="l01140" name="l01140"></a><span class="lineno"> 1140</span>    {</div>
<div class="line"><a id="l01141" name="l01141"></a><span class="lineno"> 1141</span>      <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb">perform_regular_infrequent_tasks</a>(<span class="keyword">true</span>);</div>
<div class="line"><a id="l01142" name="l01142"></a><span class="lineno"> 1142</span>    });</div>
<div class="line"><a id="l01143" name="l01143"></a><span class="lineno"> 1143</span>  }</div>
<div class="line"><a id="l01144" name="l01144"></a><span class="lineno"> 1144</span>} <span class="comment">// Node::perform_regular_infrequent_tasks()</span></div>
<div class="line"><a id="l01145" name="l01145"></a><span class="lineno"> 1145</span> </div>
<div class="line"><a id="l01146" name="l01146"></a><span class="lineno"><a class="line" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a4f4e052de75d02fb4610df872be06186"> 1146</a></span><span class="keywordtype">size_t</span> <a class="code hl_function" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a4f4e052de75d02fb4610df872be06186">Node::Socket_id::hash</a>()<span class="keyword"> const</span></div>
<div class="line"><a id="l01147" name="l01147"></a><span class="lineno"> 1147</span><span class="keyword"></span>{</div>
<div class="line"><a id="l01148" name="l01148"></a><span class="lineno"> 1148</span>  <span class="keyword">using </span>boost::hash_combine;</div>
<div class="line"><a id="l01149" name="l01149"></a><span class="lineno"> 1149</span> </div>
<div class="line"><a id="l01150" name="l01150"></a><span class="lineno"> 1150</span>  <span class="keywordtype">size_t</span> val = 0;</div>
<div class="line"><a id="l01151" name="l01151"></a><span class="lineno"> 1151</span>  hash_combine(val, <a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a23527fa6deadda111d7c4c194a0ce177">m_remote_endpoint</a>);</div>
<div class="line"><a id="l01152" name="l01152"></a><span class="lineno"> 1152</span>  hash_combine(val, <a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#aefe916d29cee30dbc344532603aa9336">m_local_port</a>);</div>
<div class="line"><a id="l01153" name="l01153"></a><span class="lineno"> 1153</span>  <span class="keywordflow">return</span> val;</div>
<div class="line"><a id="l01154" name="l01154"></a><span class="lineno"> 1154</span>}</div>
<div class="line"><a id="l01155" name="l01155"></a><span class="lineno"> 1155</span> </div>
<div class="line"><a id="l01156" name="l01156"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a99561404e8389fef08fa4ac5c16a7f36"> 1156</a></span><span class="keywordtype">bool</span> <a class="code hl_friend" href="classflow_1_1net__flow_1_1Node.html#a99561404e8389fef08fa4ac5c16a7f36">operator==</a>(<span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html">Node::Socket_id</a>&amp; lhs, <span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html">Node::Socket_id</a>&amp; rhs)</div>
<div class="line"><a id="l01157" name="l01157"></a><span class="lineno"> 1157</span>{</div>
<div class="line"><a id="l01158" name="l01158"></a><span class="lineno"> 1158</span>  <span class="keywordflow">return</span> (lhs.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#aefe916d29cee30dbc344532603aa9336">m_local_port</a> == rhs.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#aefe916d29cee30dbc344532603aa9336">m_local_port</a>) &amp;&amp; (lhs.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a23527fa6deadda111d7c4c194a0ce177">m_remote_endpoint</a> == rhs.<a class="code hl_variable" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a23527fa6deadda111d7c4c194a0ce177">m_remote_endpoint</a>);</div>
<div class="line"><a id="l01159" name="l01159"></a><span class="lineno"> 1159</span>}</div>
<div class="line"><a id="l01160" name="l01160"></a><span class="lineno"> 1160</span> </div>
<div class="line"><a id="l01161" name="l01161"></a><span class="lineno"><a class="line" href="classflow_1_1net__flow_1_1Node.html#a7e9629b88c4cd0b337a51c2363893908"> 1161</a></span><span class="keywordtype">size_t</span> <a class="code hl_friend" href="classflow_1_1net__flow_1_1Node.html#a7e9629b88c4cd0b337a51c2363893908">hash_value</a>(<span class="keyword">const</span> <a class="code hl_struct" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html">Node::Socket_id</a>&amp; <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>)</div>
<div class="line"><a id="l01162" name="l01162"></a><span class="lineno"> 1162</span>{</div>
<div class="line"><a id="l01163" name="l01163"></a><span class="lineno"> 1163</span>  <span class="keywordflow">return</span> <a class="code hl_function" href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">socket_id</a>.<a class="code hl_function" href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a4f4e052de75d02fb4610df872be06186">hash</a>();</div>
<div class="line"><a id="l01164" name="l01164"></a><span class="lineno"> 1164</span>}</div>
<div class="line"><a id="l01165" name="l01165"></a><span class="lineno"> 1165</span> </div>
<div class="line"><a id="l01166" name="l01166"></a><span class="lineno"> 1166</span>} <span class="comment">// namespace flow::net_flow</span></div>
<div class="ttc" id="aclassboost_1_1system_1_1system__error_html"><div class="ttname"><a href="classboost_1_1system_1_1system__error.html">boost::system::system_error</a></div></div>
<div class="ttc" id="aclassflow_1_1error_1_1Runtime__error_html"><div class="ttname"><a href="classflow_1_1error_1_1Runtime__error.html">flow::error::Runtime_error</a></div><div class="ttdoc">An std::runtime_error (which is an std::exception) that stores an Error_code.</div><div class="ttdef"><b>Definition:</b> <a href="error_2error_8hpp_source.html#l00047">error.hpp:49</a></div></div>
<div class="ttc" id="aclassflow_1_1log_1_1Log__context_html_af4db395042b065b00398cd59845dcb4d"><div class="ttname"><a href="classflow_1_1log_1_1Log__context.html#af4db395042b065b00398cd59845dcb4d">flow::log::Log_context::get_logger</a></div><div class="ttdeci">Logger * get_logger() const</div><div class="ttdoc">Returns the stored Logger pointer, particularly as many FLOW_LOG_*() macros expect.</div><div class="ttdef"><b>Definition:</b> <a href="log_8cpp_source.html#l00217">log.cpp:217</a></div></div>
<div class="ttc" id="aclassflow_1_1log_1_1Logger_html"><div class="ttname"><a href="classflow_1_1log_1_1Logger.html">flow::log::Logger</a></div><div class="ttdoc">Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l01280">log.hpp:1284</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Event__set_html"><div class="ttname"><a href="classflow_1_1net__flow_1_1Event__set.html">flow::net_flow::Event_set</a></div><div class="ttdoc">A user-set collection of sockets and desired conditions on those sockets (such as: &quot;socket has data t...</div><div class="ttdef"><b>Definition:</b> <a href="event__set_8hpp_source.html#l00247">event_set.hpp:254</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Event__set_html_a7e6ff0e1ad4c13220a371045101a5eff"><div class="ttname"><a href="classflow_1_1net__flow_1_1Event__set.html#a7e6ff0e1ad4c13220a371045101a5eff">flow::net_flow::Event_set::Lock_guard</a></div><div class="ttdeci">util::Lock_guard&lt; Mutex &gt; Lock_guard</div><div class="ttdoc">Short-hand for RAII lock guard of Mutex. Use instead of boost::lock_guard for release() at least.</div><div class="ttdef"><b>Definition:</b> <a href="event__set_8hpp_source.html#l00791">event_set.hpp:791</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Net__env__simulator_html"><div class="ttname"><a href="classflow_1_1net__flow_1_1Net__env__simulator.html">flow::net_flow::Net_env_simulator</a></div><div class="ttdoc">Objects of this class can be fed to Node to make it internally simulate network conditions like loss,...</div><div class="ttdef"><b>Definition:</b> <a href="net__env__simulator_8hpp_source.html#l00067">net_env_simulator.hpp:70</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html">flow::net_flow::Node</a></div><div class="ttdoc">An object of this class is a single Flow-protocol networking node, in the sense that: (1) it has a di...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00930">node.hpp:934</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a06e4cea2eefa1b06975864f09740c96b"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a06e4cea2eefa1b06975864f09740c96b">flow::net_flow::Node::handle_data_to_established</a></div><div class="ttdeci">void handle_data_to_established(const Socket_id &amp;socket_id, Peer_socket::Ptr sock, boost::shared_ptr&lt; Data_packet &gt; packet, bool syn_rcvd_qd_packet)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed, low-level DATA packet delivered to the given peer so...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l00545">peer_socket.cpp:545</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a0fba26db0055a969f3869014bc5c2bfc"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a0fba26db0055a969f3869014bc5c2bfc">flow::net_flow::Node::perform_accumulated_on_recv_tasks</a></div><div class="ttdeci">void perform_accumulated_on_recv_tasks()</div><div class="ttdoc">Performs all tasks to be performed at the end of low_lvl_recv_and_handle() or async part of async_wai...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00375">node.cpp:375</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a136d9ccd25634cee2955ea79ae829006"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a136d9ccd25634cee2955ea79ae829006">flow::net_flow::Node::handle_accumulated_acks</a></div><div class="ttdeci">void handle_accumulated_acks(const Socket_id &amp;socket_id, Peer_socket::Ptr sock)</div><div class="ttdoc">Helper of perform_accumulated_on_recv_tasks() that handles any incoming acknowledgments and rcv_wnd u...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l02017">peer_socket.cpp:2017</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a159b9c2b9a8a969f5e3715341c433aec"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a159b9c2b9a8a969f5e3715341c433aec">flow::net_flow::Node::options</a></div><div class="ttdeci">Node_options options() const</div><div class="ttdoc">Copies this Node's option set and returns that copy.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01106">node.cpp:1106</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a1699dfdaf3e5ebe1b1d715a9c306d116"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a1699dfdaf3e5ebe1b1d715a9c306d116">flow::net_flow::Node::handle_incoming</a></div><div class="ttdeci">void handle_incoming(util::Blob *packet_data, const util::Udp_endpoint &amp;low_lvl_remote_endpoint)</div><div class="ttdoc">Handles a just-received, not-yet-deserialized low-level packet.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00426">node.cpp:426</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a16c53c4848ea976b075a0b56f33eb118"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a16c53c4848ea976b075a0b56f33eb118">flow::net_flow::Node::~Node</a></div><div class="ttdeci">~Node() override</div><div class="ttdoc">Destroys Node.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00139">node.cpp:139</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a1ecd7c03349fcb26b9692d300a759463"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a1ecd7c03349fcb26b9692d300a759463">flow::net_flow::Node::S_NUM_PORTS</a></div><div class="ttdeci">static const size_t &amp; S_NUM_PORTS</div><div class="ttdoc">Total number of Flow ports in the port space, including S_PORT_ANY.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00939">node.hpp:939</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a266ec5d00a44bc48caf37444eb2b43a1"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a266ec5d00a44bc48caf37444eb2b43a1">flow::net_flow::Node::m_low_lvl_max_buf_size</a></div><div class="ttdeci">size_t m_low_lvl_max_buf_size</div><div class="ttdoc">OS-reported m_low_lvl_sock UDP receive buffer maximum size, obtained right after we OS-set that setti...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03729">node.hpp:3729</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a2779cc2429651696df1bca8de73534f3"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a2779cc2429651696df1bca8de73534f3">flow::net_flow::Node::set_options</a></div><div class="ttdeci">bool set_options(const Node_options &amp;opts, Error_code *err_code=0)</div><div class="ttdoc">Dynamically replaces the current options set (options()) with the given options set.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01054">node.cpp:1054</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a287eae1113865dba06c103cf023404ae"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a287eae1113865dba06c103cf023404ae">flow::net_flow::Node::sync_sock_low_lvl_rst_send</a></div><div class="ttdeci">void sync_sock_low_lvl_rst_send(Peer_socket::Ptr sock)</div><div class="ttdoc">Sends an RST to the other side of the given socket, synchronously.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__io_8cpp_source.html#l00997">low_lvl_io.cpp:997</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a29d02f9e302c7b06288ff1c644fa8d65"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a29d02f9e302c7b06288ff1c644fa8d65">flow::net_flow::Node::handle_syn_ack_ack_to_syn_rcvd</a></div><div class="ttdeci">void handle_syn_ack_ack_to_syn_rcvd(const Socket_id &amp;socket_id, Peer_socket::Ptr sock, boost::shared_ptr&lt; const Syn_ack_ack_packet &gt; syn_ack_ack)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed low-level SYN_ACK_ACK packet delivered to the given p...</div><div class="ttdef"><b>Definition:</b> <a href="server__socket_8cpp_source.html#l00568">server_socket.cpp:568</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a2f97b363281b79ef4f399789442c84de"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a2f97b363281b79ef4f399789442c84de">flow::net_flow::Node::S_REGULAR_INFREQUENT_TASKS_PERIOD</a></div><div class="ttdeci">static const Fine_duration S_REGULAR_INFREQUENT_TASKS_PERIOD</div><div class="ttdoc">Time interval between performing &quot;infrequent periodic tasks,&quot; such as stat logging.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03651">node.hpp:3651</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a43c42121d48a55a43a48e3a84bd10595"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a43c42121d48a55a43a48e3a84bd10595">flow::net_flow::Node::opt</a></div><div class="ttdeci">Opt_type opt(const Opt_type &amp;opt_val_ref) const</div><div class="ttdoc">Obtain a copy of the value of a given option in a thread-safe manner.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l04138">node.hpp:4138</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a446ee7115c70cbcd48e3897d32fc0276"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a446ee7115c70cbcd48e3897d32fc0276">flow::net_flow::Node::sock_validate_options</a></div><div class="ttdeci">bool sock_validate_options(const Peer_socket_options &amp;opts, const Peer_socket_options *prev_opts, Error_code *err_code) const</div><div class="ttdoc">Analogous to validate_options() but checks per-socket options instead of per-Node options.</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l06144">peer_socket.cpp:6144</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a449ef757abee4c5d12f8fc62a5ca66b4"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a449ef757abee4c5d12f8fc62a5ca66b4">flow::net_flow::Node::m_opts_mutex</a></div><div class="ttdeci">Options_mutex m_opts_mutex</div><div class="ttdoc">The mutex protecting m_opts.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03665">node.hpp:3665</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a45583714bc147300158f074ecacce0fd"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a45583714bc147300158f074ecacce0fd">flow::net_flow::Node::handle_accumulated_pending_acks</a></div><div class="ttdeci">void handle_accumulated_pending_acks(const Socket_id &amp;socket_id, Peer_socket::Ptr sock)</div><div class="ttdoc">Helper of perform_accumulated_on_recv_tasks() that handles any additional individual outgoing acknowl...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l01629">peer_socket.cpp:1629</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a4bd7b471dd6cd3e3570930b48d30e577"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a4bd7b471dd6cd3e3570930b48d30e577">flow::net_flow::Node::max_block_size</a></div><div class="ttdeci">size_t max_block_size() const</div><div class="ttdoc">The maximum number of bytes of user data per received or sent block on connections generated from thi...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01111">node.cpp:1111</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a4cb3dcb90f1dfc44a4343c0e89ce6b83"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a4cb3dcb90f1dfc44a4343c0e89ce6b83">flow::net_flow::Node::local_low_lvl_endpoint</a></div><div class="ttdeci">const util::Udp_endpoint &amp; local_low_lvl_endpoint() const</div><div class="ttdoc">Return the UDP endpoint (IP address and UDP port) which will be used for receiving incoming and sendi...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00369">node.cpp:369</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a5b056ed753b832458f44f537acfe86d7"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a5b056ed753b832458f44f537acfe86d7">flow::net_flow::Node::worker_run</a></div><div class="ttdeci">void worker_run(const util::Udp_endpoint low_lvl_endpoint)</div><div class="ttdoc">Worker thread W (main event loop) body.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00151">node.cpp:151</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a61f87144f19e908ffb981f3bff91938e"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a61f87144f19e908ffb981f3bff91938e">flow::net_flow::Node::m_event_loop_ready_result</a></div><div class="ttdeci">boost::unique_future&lt; Error_code &gt; m_event_loop_ready_result</div><div class="ttdoc">The future object through which the non-W thread waits for m_event_loop_ready to be set to success/fa...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03841">node.hpp:3841</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a6727ca42e15c8627c1ed3d94e6dd7a53"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a6727ca42e15c8627c1ed3d94e6dd7a53">flow::net_flow::Node::event_set_close_worker</a></div><div class="ttdeci">void event_set_close_worker(Event_set::Ptr event_set)</div><div class="ttdoc">The guts of event_set_close_worker_check_state(): same thing, but assumes Event_set::state() == Event...</div><div class="ttdef"><b>Definition:</b> <a href="event__set_8cpp_source.html#l01330">event_set.cpp:1330</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a74a6a82a1390a76e985593969fb47184"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a74a6a82a1390a76e985593969fb47184">flow::net_flow::Node::async_no_sock_low_lvl_rst_send</a></div><div class="ttdeci">void async_no_sock_low_lvl_rst_send(Low_lvl_packet::Const_ptr causing_packet, const util::Udp_endpoint &amp;low_lvl_remote_endpoint)</div><div class="ttdoc">Sends an RST to the given UDP endpoint in response to the given incoming low-level packet that came f...</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__io_8cpp_source.html#l00580">low_lvl_io.cpp:580</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a755c329b9e0f2b8edb2e5b900bd2a337"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a755c329b9e0f2b8edb2e5b900bd2a337">flow::net_flow::Node::sock_log_detail</a></div><div class="ttdeci">void sock_log_detail(Peer_socket::Const_ptr sock) const</div><div class="ttdoc">Logs a verbose state report for the given socket.</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l06340">peer_socket.cpp:6340</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a7aadcad6c19587cd0d788570194b2afd"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a7aadcad6c19587cd0d788570194b2afd">flow::net_flow::Node::S_NUM_EPHEMERAL_PORTS</a></div><div class="ttdeci">static const size_t &amp; S_NUM_EPHEMERAL_PORTS</div><div class="ttdoc">Total number of Flow &quot;ephemeral&quot; ports (ones reserved locally at random with Node::listen(S_PORT_ANY)...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00948">node.hpp:948</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a7bea132db0e45ea01b9a6bd22fd0fadb"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a7bea132db0e45ea01b9a6bd22fd0fadb">flow::net_flow::Node::m_socks_with_accumulated_pending_acks</a></div><div class="ttdeci">boost::unordered_set&lt; Peer_socket::Ptr &gt; m_socks_with_accumulated_pending_acks</div><div class="ttdoc">Within a given low_lvl_recv_and_handle() or async part of async_wait_latency_then_handle_incoming() (...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03807">node.hpp:3807</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a7d9f418a3c99197e58f71ce2fff2997f"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a7d9f418a3c99197e58f71ce2fff2997f">flow::net_flow::Node::m_socks_with_accumulated_acks</a></div><div class="ttdeci">boost::unordered_set&lt; Peer_socket::Ptr &gt; m_socks_with_accumulated_acks</div><div class="ttdoc">Within a given low_lvl_recv_and_handle() or async part of async_wait_latency_then_handle_incoming() c...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03825">node.hpp:3825</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a7e9629b88c4cd0b337a51c2363893908"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a7e9629b88c4cd0b337a51c2363893908">flow::net_flow::Node::hash_value</a></div><div class="ttdeci">friend size_t hash_value(const Socket_id &amp;socket_id)</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01161">node.cpp:1161</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a84b7e03ae7b13dae0f59db1475e46fd3"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a84b7e03ae7b13dae0f59db1475e46fd3">flow::net_flow::Node::m_worker</a></div><div class="ttdeci">util::Thread m_worker</div><div class="ttdoc">Worker thread (= thread W). Other members should be initialized before this to avoid race condition.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03851">node.hpp:3851</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a8a4ddf81ddbeab1f740940c4cc0d3625"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a8a4ddf81ddbeab1f740940c4cc0d3625">flow::net_flow::Node::event_set_all_check_delta</a></div><div class="ttdeci">void event_set_all_check_delta(bool defer_delta_check)</div><div class="ttdoc">For each WAITING Event_set within the Node: checks for any events that hold, and if any do hold,...</div><div class="ttdef"><b>Definition:</b> <a href="event__set_8cpp_source.html#l01127">event_set.cpp:1127</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a90244d69d550370158bbe843ab595a7a"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a90244d69d550370158bbe843ab595a7a">flow::net_flow::Node::m_socks</a></div><div class="ttdeci">Socket_id_to_socket_map m_socks</div><div class="ttdoc">The peer-to-peer connections this Node is currently tracking.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03750">node.hpp:3750</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a9511f3ba50d19f2c32a8de94f0a306e8"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a9511f3ba50d19f2c32a8de94f0a306e8">flow::net_flow::Node::validate_option_check</a></div><div class="ttdeci">bool validate_option_check(bool check, const std::string &amp;check_str, Error_code *err_code) const</div><div class="ttdoc">Helper that, if the given condition is false, logs and returns an error; used to check for option val...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01092">node.cpp:1092</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a96b593d90c246cb2e35fc6a0834e6876"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a96b593d90c246cb2e35fc6a0834e6876">flow::net_flow::Node::S_FIRST_SERVICE_PORT</a></div><div class="ttdeci">static const flow_port_t &amp; S_FIRST_SERVICE_PORT</div><div class="ttdoc">The port number of the lowest service port, making the range of service ports [S_FIRST_SERVICE_PORT,...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00954">node.hpp:954</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a97c8679c70ac9c7dda394fdf335aaed7"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a97c8679c70ac9c7dda394fdf335aaed7">flow::net_flow::Node::Options_lock</a></div><div class="ttdeci">Peer_socket::Options_lock Options_lock</div><div class="ttdoc">Short-hand for lock that acquires exclusive access to an Options_mutex.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l01436">node.hpp:1436</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a99561404e8389fef08fa4ac5c16a7f36"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a99561404e8389fef08fa4ac5c16a7f36">flow::net_flow::Node::operator==</a></div><div class="ttdeci">friend bool operator==(const Socket_id &amp;lhs, const Socket_id &amp;rhs)</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01156">node.cpp:1156</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a99836ffb51eaefa4d2cc21770461cd97"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a99836ffb51eaefa4d2cc21770461cd97">flow::net_flow::Node::socket_id</a></div><div class="ttdeci">static Socket_id socket_id(Peer_socket::Const_ptr sock)</div><div class="ttdoc">Constructs the socket pair (connection ID) for the given socket.</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l05973">peer_socket.cpp:5973</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_a9b9e0224c17190e99debdfd81640bf89"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#a9b9e0224c17190e99debdfd81640bf89">flow::net_flow::Node::m_low_lvl_sock</a></div><div class="ttdeci">Udp_socket m_low_lvl_sock</div><div class="ttdoc">The UDP socket used to receive low-level packets (to assemble into application layer data) and send t...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03711">node.hpp:3711</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aa0f9ebea458490c37a38760c8335506c"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aa0f9ebea458490c37a38760c8335506c">flow::net_flow::Node::handle_syn_ack_to_syn_sent</a></div><div class="ttdeci">void handle_syn_ack_to_syn_sent(const Socket_id &amp;socket_id, Peer_socket::Ptr sock, boost::shared_ptr&lt; const Syn_ack_packet &gt; syn_ack)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed low-level SYN_ACK packet delivered to the given peer ...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l00464">peer_socket.cpp:464</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aa1b913c5c759a465a9fcaa637ddaea99"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aa1b913c5c759a465a9fcaa637ddaea99">flow::net_flow::Node::S_NUM_SERVICE_PORTS</a></div><div class="ttdeci">static const size_t &amp; S_NUM_SERVICE_PORTS</div><div class="ttdoc">Total number of Flow &quot;service&quot; ports (ones that can be reserved by number with Node::listen()).</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00942">node.hpp:942</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aa1d1021e099c70c1a6e192e65f86debf"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aa1d1021e099c70c1a6e192e65f86debf">flow::net_flow::Node::S_FIRST_EPHEMERAL_PORT</a></div><div class="ttdeci">static const flow_port_t &amp; S_FIRST_EPHEMERAL_PORT</div><div class="ttdoc">The port number of the lowest ephemeral Flow port, making the range of ephemeral ports [S_FIRST_EPHEM...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l00960">node.hpp:960</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aa440f6ff5442c58323bec7a2304b0d90"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aa440f6ff5442c58323bec7a2304b0d90">flow::net_flow::Node::m_event_loop_ready</a></div><div class="ttdeci">boost::promise&lt; Error_code &gt; m_event_loop_ready</div><div class="ttdoc">Promise that thread W sets to truthy Error_code if it fails to initialize or falsy once event loop is...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03838">node.hpp:3838</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aa894fd58b246c2a8d6c7c7d25a8748cb"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aa894fd58b246c2a8d6c7c7d25a8748cb">flow::net_flow::Node::this_thread_init_logger_setup</a></div><div class="ttdeci">log::Logger * this_thread_init_logger_setup(const std::string &amp;thread_type, log::Logger *logger=0)</div><div class="ttdoc">Helper to invoke for each thread in which this Node executes, whether or not it starts that thread,...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00113">node.cpp:113</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aaaf5c3b5e6b9f9f1658b60907b36a498"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aaaf5c3b5e6b9f9f1658b60907b36a498">flow::net_flow::Node::handle_syn_to_listening_server</a></div><div class="ttdeci">Peer_socket::Ptr handle_syn_to_listening_server(Server_socket::Ptr serv, boost::shared_ptr&lt; const Syn_packet &gt; syn, const util::Udp_endpoint &amp;low_lvl_remote_endpoint)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed low-level SYN packet delivered to the given server so...</div><div class="ttdef"><b>Definition:</b> <a href="server__socket_8cpp_source.html#l00430">server_socket.cpp:430</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aae148cec361b59237996a4b30c6624b5"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aae148cec361b59237996a4b30c6624b5">flow::net_flow::Node::running</a></div><div class="ttdeci">bool running() const</div><div class="ttdoc">Returns true if and only if the Node is operating.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00420">node.cpp:420</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aae28990628a86a07327f49973f2390df"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aae28990628a86a07327f49973f2390df">flow::net_flow::Node::m_servs</a></div><div class="ttdeci">Port_to_server_map m_servs</div><div class="ttdoc">The server sockets this Node is currently tracking.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03756">node.hpp:3756</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ab2595f47710ddb06cfb22b6710b7286e"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ab2595f47710ddb06cfb22b6710b7286e">flow::net_flow::Node::validate_options</a></div><div class="ttdeci">const Node_options &amp; validate_options(const Node_options &amp;opts, bool init, Error_code *err_code) const</div><div class="ttdoc">Given a new set of Node_options intended to replace (or initialize) a Node's m_opts,...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00980">node.cpp:980</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ab515b28350c43635728d6de0e37ccb94"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ab515b28350c43635728d6de0e37ccb94">flow::net_flow::Node::handle_ack_to_established</a></div><div class="ttdeci">void handle_ack_to_established(Peer_socket::Ptr sock, boost::shared_ptr&lt; const Ack_packet &gt; ack)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed, low-level ACK packet delivered to the given peer soc...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l01946">peer_socket.cpp:1946</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_abb3d760b3c880b41e5a4ee7f2c13fd81"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#abb3d760b3c880b41e5a4ee7f2c13fd81">flow::net_flow::Node::handle_syn_ack_to_established</a></div><div class="ttdeci">void handle_syn_ack_to_established(Peer_socket::Ptr sock, boost::shared_ptr&lt; const Syn_ack_packet &gt; syn_ack)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed, duplicate (equal to already-received SYN_ACK) low-le...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l00524">peer_socket.cpp:524</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_abecf0f8111af82fa081c71fda490608a"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#abecf0f8111af82fa081c71fda490608a">flow::net_flow::Node::m_signal_set</a></div><div class="ttdeci">Signal_set m_signal_set</div><div class="ttdoc">Signal set which we may or may not be using to trap SIGINT and SIGTERM in order to auto-fire interrup...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03848">node.hpp:3848</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_abf80b7de1398e93d1d4289ef5bf2ae2c"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#abf80b7de1398e93d1d4289ef5bf2ae2c">flow::net_flow::Node::handle_data_to_syn_rcvd</a></div><div class="ttdeci">void handle_data_to_syn_rcvd(Peer_socket::Ptr sock, boost::shared_ptr&lt; Data_packet &gt; packet)</div><div class="ttdoc">Handles a just-deserialized, just-demultiplexed, low-level DATA packet delivered to the given peer so...</div><div class="ttdef"><b>Definition:</b> <a href="server__socket_8cpp_source.html#l00686">server_socket.cpp:686</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_acd93ba39d6a9cdee60c2ad7da1085902"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#acd93ba39d6a9cdee60c2ad7da1085902">flow::net_flow::Node::Node</a></div><div class="ttdeci">Node(log::Logger *logger, const util::Udp_endpoint &amp;low_lvl_endpoint, Net_env_simulator *net_env_sim=0, Error_code *err_code=0, const Node_options &amp;opts=Node_options())</div><div class="ttdoc">Constructs Node.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l00040">node.cpp:40</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ad03aa88df3d1d3981454ee3356e868c1"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ad03aa88df3d1d3981454ee3356e868c1">flow::net_flow::Node::async_sock_low_lvl_rst_send</a></div><div class="ttdeci">void async_sock_low_lvl_rst_send(Peer_socket::Ptr sock)</div><div class="ttdoc">Sends an RST to the other side of the given socket asynchronously when possible.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__io_8cpp_source.html#l00988">low_lvl_io.cpp:988</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ade08f0457943f803c23b55649139c0d3"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ade08f0457943f803c23b55649139c0d3">flow::net_flow::Node::m_opts</a></div><div class="ttdeci">Node_options m_opts</div><div class="ttdoc">This Node's global set of options.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03662">node.hpp:3662</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ade12d2ebbd88b62432089a3a071b9514"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ade12d2ebbd88b62432089a3a071b9514">flow::net_flow::Node::async_low_lvl_recv</a></div><div class="ttdeci">void async_low_lvl_recv()</div><div class="ttdoc">Registers so that during the current or next m_task_engine.run(), the latter will wait for a receivab...</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__io_8cpp_source.html#l00031">low_lvl_io.cpp:31</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ade49e7bc7202a0adf33fec2d93d1b177"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ade49e7bc7202a0adf33fec2d93d1b177">flow::net_flow::Node::close_connection_immediately</a></div><div class="ttdeci">void close_connection_immediately(const Socket_id &amp;socket_id, Peer_socket::Ptr sock, const Error_code &amp;err_code, bool defer_delta_check)</div><div class="ttdoc">A thread W method that handles the transition of the given socket from OPEN (any sub-state) to CLOSED...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8cpp_source.html#l05600">peer_socket.cpp:5600</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_adf6d71af81def2d030f0fef159c1b06d"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#adf6d71af81def2d030f0fef159c1b06d">flow::net_flow::Node::close_empty_server_immediately</a></div><div class="ttdeci">void close_empty_server_immediately(const flow_port_t local_port, Server_socket::Ptr serv, const Error_code &amp;err_code, bool defer_delta_check)</div><div class="ttdoc">Handles the transition of the given server socket from S_LISTENING/S_CLOSING to S_CLOSED (including e...</div><div class="ttdef"><b>Definition:</b> <a href="server__socket_8cpp_source.html#l00361">server_socket.cpp:361</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ae43345472c4f41933a9c16d114cc937b"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ae43345472c4f41933a9c16d114cc937b">flow::net_flow::Node::m_event_sets</a></div><div class="ttdeci">Event_sets m_event_sets</div><div class="ttdoc">Every Event_set to have been returned by event_set_create() and not subsequently reached Event_set::S...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03762">node.hpp:3762</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_ae996cab95eb139d00f0d430093e64a5f"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#ae996cab95eb139d00f0d430093e64a5f">flow::net_flow::Node::interrupt_all_waits_internal_sig_handler</a></div><div class="ttdeci">void interrupt_all_waits_internal_sig_handler(const Error_code &amp;sys_err_code, int sig_number)</div><div class="ttdoc">signal_set handler, executed on SIGINT and SIGTERM, if user has enabled this feature: causes interrup...</div><div class="ttdef"><b>Definition:</b> <a href="event__set_8cpp_source.html#l01454">event_set.cpp:1454</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aee8466d9c810da5edea443d665b24dcb"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aee8466d9c810da5edea443d665b24dcb">flow::net_flow::Node::perform_regular_infrequent_tasks</a></div><div class="ttdeci">void perform_regular_infrequent_tasks(bool reschedule)</div><div class="ttdoc">Performs low-priority tasks that should be run on an infrequent, regular basis, such as stat logging ...</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01116">node.cpp:1116</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_aee89be07daf7d024921381a4bafe1289"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#aee89be07daf7d024921381a4bafe1289">flow::net_flow::Node::m_low_lvl_endpoint</a></div><div class="ttdeci">util::Udp_endpoint m_low_lvl_endpoint</div><div class="ttdoc">After we bind m_low_lvl_sock to a UDP endpoint, this is a copy of that endpoint.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03722">node.hpp:3722</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Node_html_af5597a417d03e2bed87cd772ef5cef29"><div class="ttname"><a href="classflow_1_1net__flow_1_1Node.html#af5597a417d03e2bed87cd772ef5cef29">flow::net_flow::Node::m_task_engine</a></div><div class="ttdeci">util::Task_engine m_task_engine</div><div class="ttdoc">The main loop engine, functioning in the single-threaded-but-asynchronous callback-based &quot;reactor&quot; st...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03697">node.hpp:3697</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Peer__socket_html_a9537860c2c2a7380a45a525e5121880f"><div class="ttname"><a href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880f">flow::net_flow::Peer_socket::Int_state</a></div><div class="ttdeci">Int_state</div><div class="ttdoc">The state of the socket (and the connection from this end's point of view) for the internal state mac...</div><div class="ttdef"><b>Definition:</b> <a href="peer__socket_8hpp_source.html#l00910">peer_socket.hpp:911</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Peer__socket_html_a9537860c2c2a7380a45a525e5121880fa16fdfce85d7bca9386378acd29eb7202"><div class="ttname"><a href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa16fdfce85d7bca9386378acd29eb7202">flow::net_flow::Peer_socket::Int_state::S_ESTABLISHED</a></div><div class="ttdeci">@ S_ESTABLISHED</div><div class="ttdoc">Public state is OPEN+CONNECTED; in our opinion the connection is established.</div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Peer__socket_html_a9537860c2c2a7380a45a525e5121880fa20112c63421f4aa5d77b5d5ba5b10c87"><div class="ttname"><a href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa20112c63421f4aa5d77b5d5ba5b10c87">flow::net_flow::Peer_socket::Int_state::S_SYN_SENT</a></div><div class="ttdeci">@ S_SYN_SENT</div><div class="ttdoc">Public state is OPEN+CONNECTING; user requested active connect; we sent SYN and are awaiting response...</div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Peer__socket_html_a9537860c2c2a7380a45a525e5121880fa6abcbd1be8478aa03e76aec9c540e14f"><div class="ttname"><a href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa6abcbd1be8478aa03e76aec9c540e14f">flow::net_flow::Peer_socket::Int_state::S_CLOSED</a></div><div class="ttdeci">@ S_CLOSED</div><div class="ttdoc">Closed (dead or new) socket.</div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Peer__socket_html_a9537860c2c2a7380a45a525e5121880fa9838c717b26793d3b5360e4d718dc2d2"><div class="ttname"><a href="classflow_1_1net__flow_1_1Peer__socket.html#a9537860c2c2a7380a45a525e5121880fa9838c717b26793d3b5360e4d718dc2d2">flow::net_flow::Peer_socket::Int_state::S_SYN_RCVD</a></div><div class="ttdeci">@ S_SYN_RCVD</div><div class="ttdoc">Public state is OPEN+CONNECTING; other side requested passive connect via SYN; we sent SYN_ACK and ar...</div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Port__space_html_a06fb009aafc77f75241f721734fe3cc4"><div class="ttname"><a href="classflow_1_1net__flow_1_1Port__space.html#a06fb009aafc77f75241f721734fe3cc4">flow::net_flow::Port_space::S_NUM_EPHEMERAL_PORTS</a></div><div class="ttdeci">static const size_t S_NUM_EPHEMERAL_PORTS</div><div class="ttdoc">Total number of &quot;ephemeral&quot; ports (ones reserved at random with reserve_ephemeral_port()).</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8hpp_source.html#l00105">port_space.hpp:105</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Port__space_html_a6d07833521960b2f90806bfa7728cfd8"><div class="ttname"><a href="classflow_1_1net__flow_1_1Port__space.html#a6d07833521960b2f90806bfa7728cfd8">flow::net_flow::Port_space::S_FIRST_SERVICE_PORT</a></div><div class="ttdeci">static const flow_port_t S_FIRST_SERVICE_PORT</div><div class="ttdoc">The port number of the lowest service port.</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8hpp_source.html#l00108">port_space.hpp:108</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Port__space_html_ab9a614b67638cbd9526eb82033a53352"><div class="ttname"><a href="classflow_1_1net__flow_1_1Port__space.html#ab9a614b67638cbd9526eb82033a53352">flow::net_flow::Port_space::S_FIRST_EPHEMERAL_PORT</a></div><div class="ttdeci">static const flow_port_t S_FIRST_EPHEMERAL_PORT</div><div class="ttdoc">The port number of the lowest ephemeral port.</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8hpp_source.html#l00111">port_space.hpp:111</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Port__space_html_ad93c0b6f23be37efe0f96ab066ff9bf8"><div class="ttname"><a href="classflow_1_1net__flow_1_1Port__space.html#ad93c0b6f23be37efe0f96ab066ff9bf8">flow::net_flow::Port_space::S_NUM_SERVICE_PORTS</a></div><div class="ttdeci">static const size_t S_NUM_SERVICE_PORTS</div><div class="ttdoc">Total number of &quot;service&quot; ports (ones that can be reserved by number with reserve_port()).</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8hpp_source.html#l00102">port_space.hpp:102</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Port__space_html_af0c60ec4732021d52a19e5d2f6dc8b35"><div class="ttname"><a href="classflow_1_1net__flow_1_1Port__space.html#af0c60ec4732021d52a19e5d2f6dc8b35">flow::net_flow::Port_space::S_NUM_PORTS</a></div><div class="ttdeci">static const size_t S_NUM_PORTS</div><div class="ttdoc">Total number of ports in the port space, including S_PORT_ANY.</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8hpp_source.html#l00099">port_space.hpp:99</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Server__socket_html_a8bc789b851677a47d7c0a1aa0c69a997"><div class="ttname"><a href="classflow_1_1net__flow_1_1Server__socket.html#a8bc789b851677a47d7c0a1aa0c69a997">flow::net_flow::Server_socket::State</a></div><div class="ttdeci">State</div><div class="ttdoc">State of a Server_socket.</div><div class="ttdef"><b>Definition:</b> <a href="server__socket_8hpp_source.html#l00131">server_socket.hpp:132</a></div></div>
<div class="ttc" id="aclassflow_1_1net__flow_1_1Server__socket_html_a8bc789b851677a47d7c0a1aa0c69a997aebae5ec546409cde4d74d99452d9cc8a"><div class="ttname"><a href="classflow_1_1net__flow_1_1Server__socket.html#a8bc789b851677a47d7c0a1aa0c69a997aebae5ec546409cde4d74d99452d9cc8a">flow::net_flow::Server_socket::State::S_LISTENING</a></div><div class="ttdeci">@ S_LISTENING</div><div class="ttdoc">Future or current accept()s may be possible. A socket in this state may be Acceptable.</div></div>
<div class="ttc" id="aclassflow_1_1util_1_1Shared__ptr__alias__holder_html_aa4f1af88393042e60159a3a67f0accbc"><div class="ttname"><a href="classflow_1_1util_1_1Shared__ptr__alias__holder.html#aa4f1af88393042e60159a3a67f0accbc">flow::util::Shared_ptr_alias_holder&lt; boost::shared_ptr&lt; Event_set &gt; &gt;::Ptr</a></div><div class="ttdeci">boost::shared_ptr&lt; Event_set &gt; Ptr</div><div class="ttdoc">Short-hand for ref-counted pointer to mutable values of type Target_type::element_type (a-la T*).</div><div class="ttdef"><b>Definition:</b> <a href="shared__ptr__alias__holder_8hpp_source.html#l00125">shared_ptr_alias_holder.hpp:125</a></div></div>
<div class="ttc" id="aendpoint_8hpp_html"><div class="ttname"><a href="endpoint_8hpp.html">endpoint.hpp</a></div></div>
<div class="ttc" id="aerror_2error_8hpp_html_a019ee6e90802e444572dd78d312d6e23"><div class="ttname"><a href="error_2error_8hpp.html#a019ee6e90802e444572dd78d312d6e23">FLOW_ERROR_SYS_ERROR_LOG_WARNING</a></div><div class="ttdeci">#define FLOW_ERROR_SYS_ERROR_LOG_WARNING()</div><div class="ttdoc">Logs a warning about the (often errno-based or from a library) error code in sys_err_code.</div><div class="ttdef"><b>Definition:</b> <a href="error_2error_8hpp_source.html#l00269">error.hpp:269</a></div></div>
<div class="ttc" id="aerror_2error_8hpp_html_a636b2d30a8785df6e84646b568bce9b5"><div class="ttname"><a href="error_2error_8hpp.html#a636b2d30a8785df6e84646b568bce9b5">FLOW_ERROR_EXEC_AND_THROW_ON_ERROR</a></div><div class="ttdeci">#define FLOW_ERROR_EXEC_AND_THROW_ON_ERROR(ARG_ret_type, ARG_function_name,...)</div><div class="ttdoc">Narrow-use macro that implements the error code/exception semantics expected of most public-facing Fl...</div><div class="ttdef"><b>Definition:</b> <a href="error_2error_8hpp_source.html#l00363">error.hpp:363</a></div></div>
<div class="ttc" id="aerror_2error_8hpp_html_ab6b8ed79012c994cfc381e0b92c066fd"><div class="ttname"><a href="error_2error_8hpp.html#ab6b8ed79012c994cfc381e0b92c066fd">FLOW_ERROR_EMIT_ERROR</a></div><div class="ttdeci">#define FLOW_ERROR_EMIT_ERROR(ARG_val)</div><div class="ttdoc">Sets *err_code to ARG_val and logs a warning about the error using FLOW_LOG_WARNING().</div><div class="ttdef"><b>Definition:</b> <a href="error_2error_8hpp_source.html#l00202">error.hpp:202</a></div></div>
<div class="ttc" id="alog_8hpp_html_a325fdd4b5cf0be49b37d3b7b7c29070d"><div class="ttname"><a href="log_8hpp.html#a325fdd4b5cf0be49b37d3b7b7c29070d">FLOW_LOG_INFO</a></div><div class="ttdeci">#define FLOW_LOG_INFO(ARG_stream_fragment)</div><div class="ttdoc">Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l00197">log.hpp:197</a></div></div>
<div class="ttc" id="alog_8hpp_html_a626c7dc4d3b4dc0b32a8aac8624d66bc"><div class="ttname"><a href="log_8hpp.html#a626c7dc4d3b4dc0b32a8aac8624d66bc">FLOW_LOG_WARNING</a></div><div class="ttdeci">#define FLOW_LOG_WARNING(ARG_stream_fragment)</div><div class="ttdoc">Logs a WARNING message into flow::log::Logger *get_logger() with flow::log::Component get_log_compone...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l00152">log.hpp:152</a></div></div>
<div class="ttc" id="alog_8hpp_html_affcf2e4c496ce3f42adf981669c623b8"><div class="ttname"><a href="log_8hpp.html#affcf2e4c496ce3f42adf981669c623b8">FLOW_LOG_TRACE</a></div><div class="ttdeci">#define FLOW_LOG_TRACE(ARG_stream_fragment)</div><div class="ttdoc">Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...</div><div class="ttdef"><b>Definition:</b> <a href="log_8hpp_source.html#l00227">log.hpp:227</a></div></div>
<div class="ttc" id="anamespaceflow_1_1log_html_aaaaa1dcbf7c8dc99aceb2b6c217187fc"><div class="ttname"><a href="namespaceflow_1_1log.html#aaaaa1dcbf7c8dc99aceb2b6c217187fc">flow::log::beautify_chrono_logger_this_thread</a></div><div class="ttdeci">void beautify_chrono_logger_this_thread(Logger *logger_ptr)</div><div class="ttdoc">Sets certain chrono-related formatting on the given Logger in the current thread that results in a co...</div><div class="ttdef"><b>Definition:</b> <a href="log_8cpp_source.html#l00271">log.cpp:271</a></div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a138a08bb4d41be4cdbc6311a1a617cf4">flow::net_flow::error::Code::S_CONN_RESET_BY_OTHER_SIDE</a></div><div class="ttdeci">@ S_CONN_RESET_BY_OTHER_SIDE</div><div class="ttdoc">Other side reset an established connection.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5d57c6a6029d7c6a9e5442ac72ac7a6b">flow::net_flow::error::Code::S_NODE_SHUTTING_DOWN</a></div><div class="ttdeci">@ S_NODE_SHUTTING_DOWN</div><div class="ttdoc">Node shutting down.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482a5e0c2b54a5427bc09ecf0dee603ce450">flow::net_flow::error::Code::S_OPTION_CHECK_FAILED</a></div><div class="ttdeci">@ S_OPTION_CHECK_FAILED</div><div class="ttdoc">When setting options, at least one option's value violates a required condition on that option.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482aa220d89e1d0e34bab02ed2fc7512be9b">flow::net_flow::error::Code::S_CONN_REFUSED</a></div><div class="ttdeci">@ S_CONN_REFUSED</div><div class="ttdoc">Other side refused connection.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482ab2c97d0fbc585d3726ec79c7802da891">flow::net_flow::error::Code::S_CONN_RESET_BAD_PEER_BEHAVIOR</a></div><div class="ttdeci">@ S_CONN_RESET_BAD_PEER_BEHAVIOR</div><div class="ttdoc">Connection reset because of unexpected/illegal behavior by the other side.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_1_1error_html_a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e"><div class="ttname"><a href="namespaceflow_1_1net__flow_1_1error.html#a18e13de77b119ea0f2be411490859482affac5d80b4e72f2e55bbbfadce2efd2e">flow::net_flow::error::Code::S_NODE_NOT_RUNNING</a></div><div class="ttdeci">@ S_NODE_NOT_RUNNING</div><div class="ttdoc">Node not running.</div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_html"><div class="ttname"><a href="namespaceflow_1_1net__flow.html">flow::net_flow</a></div><div class="ttdoc">Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...</div><div class="ttdef"><b>Definition:</b> <a href="asio_2node_8cpp_source.html#l00024">node.cpp:25</a></div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_html_a079d8cd87a68d1c5f04c6bce71f0061d"><div class="ttname"><a href="namespaceflow_1_1net__flow.html#a079d8cd87a68d1c5f04c6bce71f0061d">flow::net_flow::flow_port_t</a></div><div class="ttdeci">uint16_t flow_port_t</div><div class="ttdoc">Logical Flow port type (analogous to a UDP/TCP port in spirit but in no way relevant to UDP/TCP).</div><div class="ttdef"><b>Definition:</b> <a href="net__flow__fwd_8hpp_source.html#l00054">net_flow_fwd.hpp:54</a></div></div>
<div class="ttc" id="anamespaceflow_1_1net__flow_html_a9dd0c9d8de00fab78d8b0a3f50dad2a9"><div class="ttname"><a href="namespaceflow_1_1net__flow.html#a9dd0c9d8de00fab78d8b0a3f50dad2a9">flow::net_flow::S_PORT_ANY</a></div><div class="ttdeci">const flow_port_t S_PORT_ANY</div><div class="ttdoc">Special Flow port value used to indicate &quot;invalid port&quot; or &quot;please pick a random available ephemeral ...</div><div class="ttdef"><b>Definition:</b> <a href="port__space_8cpp_source.html#l00033">port_space.cpp:33</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_a74d4a66fb00055be4e1bd6ee98e04667"><div class="ttname"><a href="namespaceflow_1_1util.html#a74d4a66fb00055be4e1bd6ee98e04667">flow::util::schedule_task_from_now</a></div><div class="ttdeci">Scheduled_task_handle schedule_task_from_now(log::Logger *logger_ptr, const Fine_duration &amp;from_now, bool single_threaded, Task_engine *task_engine, Scheduled_task_handler &amp;&amp;task_body_moved)</div><div class="ttdoc">Schedule the given function to execute in a certain amount of time: A handy wrapper around Timer (asi...</div><div class="ttdef"><b>Definition:</b> <a href="sched__task_8hpp_source.html#l00034">sched_task.hpp:34</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_a8afd30c50bcd670d45442df49d1da484"><div class="ttname"><a href="namespaceflow_1_1util.html#a8afd30c50bcd670d45442df49d1da484">flow::util::ostream_op_to_string</a></div><div class="ttdeci">void ostream_op_to_string(std::string *target_str, T const &amp;... ostream_args)</div><div class="ttdoc">Writes to the specified string, as if the given arguments were each passed, via &lt;&lt; in sequence,...</div><div class="ttdef"><b>Definition:</b> <a href="util_2util_8hpp_source.html#l00367">util.hpp:367</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_af09888b3a8feaff209b6625e493bc338"><div class="ttname"><a href="namespaceflow_1_1util.html#af09888b3a8feaff209b6625e493bc338">flow::util::Blob</a></div><div class="ttdeci">Blob_with_log_context&lt;&gt; Blob</div><div class="ttdoc">A concrete Blob_with_log_context that compile-time-disables Basic_blob::share() and the sharing API d...</div><div class="ttdef"><b>Definition:</b> <a href="blob__fwd_8hpp_source.html#l00060">blob_fwd.hpp:60</a></div></div>
<div class="ttc" id="anamespaceflow_1_1util_html_af1b28edb7bad743c1c77f6b982cc3196"><div class="ttname"><a href="namespaceflow_1_1util.html#af1b28edb7bad743c1c77f6b982cc3196">flow::util::Udp_endpoint</a></div><div class="ttdeci">boost::asio::ip::udp::endpoint Udp_endpoint</div><div class="ttdoc">Short-hand for the UDP endpoint (IP/port) type.</div><div class="ttdef"><b>Definition:</b> <a href="util__fwd_8hpp_source.html#l00208">util_fwd.hpp:208</a></div></div>
<div class="ttc" id="anamespaceflow_html_a29eaaa9d0fac4ce87d8b969222dbed09"><div class="ttname"><a href="namespaceflow.html#a29eaaa9d0fac4ce87d8b969222dbed09">flow::Error_code</a></div><div class="ttdeci">boost::system::error_code Error_code</div><div class="ttdoc">Short-hand for a boost.system error code (which basically encapsulates an integer/enum error code and...</div><div class="ttdef"><b>Definition:</b> <a href="common_8hpp_source.html#l00508">common.hpp:508</a></div></div>
<div class="ttc" id="anamespaceflow_html_a3938730ab4b89daf13d027a5f620e7ce"><div class="ttname"><a href="namespaceflow.html#a3938730ab4b89daf13d027a5f620e7ce">flow::Flow_log_component</a></div><div class="ttdeci">Flow_log_component</div><div class="ttdoc">The flow::log::Component payload enumeration comprising various log components used by Flow's own int...</div><div class="ttdef"><b>Definition:</b> <a href="common_8hpp_source.html#l00637">common.hpp:638</a></div></div>
<div class="ttc" id="anamespaceflow_html_a48799f1263cdeedec125be51a3db2b79"><div class="ttname"><a href="namespaceflow.html#a48799f1263cdeedec125be51a3db2b79">flow::Fine_duration</a></div><div class="ttdeci">Fine_clock::duration Fine_duration</div><div class="ttdoc">A high-res time duration as computed from two Fine_time_pts.</div><div class="ttdef"><b>Definition:</b> <a href="common_8hpp_source.html#l00416">common.hpp:416</a></div></div>
<div class="ttc" id="anode_8hpp_html"><div class="ttname"><a href="node_8hpp.html">node.hpp</a></div></div>
<div class="ttc" id="asched__task_8hpp_html"><div class="ttname"><a href="sched__task_8hpp.html">sched_task.hpp</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Ack__packet_1_1Individual__ack_html_abbd41e30089125f67667b39f5756c275"><div class="ttname"><a href="structflow_1_1net__flow_1_1Ack__packet_1_1Individual__ack.html#abbd41e30089125f67667b39f5756c275">flow::net_flow::Ack_packet::Individual_ack::Ptr</a></div><div class="ttdeci">boost::shared_ptr&lt; Individual_ack &gt; Ptr</div><div class="ttdoc">Short-hand for ref-counted pointer to mutable objects of this class.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l01201">low_lvl_packet.hpp:1201</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Ack__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Ack__packet.html">flow::net_flow::Ack_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level ACK packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l01020">low_lvl_packet.hpp:1021</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Data__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Data__packet.html">flow::net_flow::Data_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level DATA packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l00893">low_lvl_packet.hpp:894</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Low__lvl__packet_html_a186d7dae0c4b4402aed22a25d595ed30"><div class="ttname"><a href="structflow_1_1net__flow_1_1Low__lvl__packet.html#a186d7dae0c4b4402aed22a25d595ed30">flow::net_flow::Low_lvl_packet::create_from_raw_data_packet</a></div><div class="ttdeci">static Ptr create_from_raw_data_packet(log::Logger *logger_ptr, util::Blob *raw_packet, bool prefer_no_move)</div><div class="ttdoc">Constructs packet on the heap with values determined by the given raw binary data as presumably recei...</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8cpp_source.html#l00380">low_lvl_packet.cpp:380</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node_1_1Socket__id_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html">flow::net_flow::Node::Socket_id</a></div><div class="ttdoc">The data nugget uniquely identifying a peer-to-peer connection from a remote endpoint to a port in th...</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03861">node.hpp:3862</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node_1_1Socket__id_html_a23527fa6deadda111d7c4c194a0ce177"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a23527fa6deadda111d7c4c194a0ce177">flow::net_flow::Node::Socket_id::m_remote_endpoint</a></div><div class="ttdeci">const Remote_endpoint m_remote_endpoint</div><div class="ttdoc">The other side of the connection.</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03866">node.hpp:3866</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node_1_1Socket__id_html_a4f4e052de75d02fb4610df872be06186"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#a4f4e052de75d02fb4610df872be06186">flow::net_flow::Node::Socket_id::hash</a></div><div class="ttdeci">size_t hash() const</div><div class="ttdoc">Hash value of this Socket_id for unordered&lt;&gt;.</div><div class="ttdef"><b>Definition:</b> <a href="node_8cpp_source.html#l01146">node.cpp:1146</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node_1_1Socket__id_html_aefe916d29cee30dbc344532603aa9336"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node_1_1Socket__id.html#aefe916d29cee30dbc344532603aa9336">flow::net_flow::Node::Socket_id::m_local_port</a></div><div class="ttdeci">const flow_port_t m_local_port</div><div class="ttdoc">This side of the connection (within this Node).</div><div class="ttdef"><b>Definition:</b> <a href="node_8hpp_source.html#l03868">node.hpp:3868</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html">flow::net_flow::Node_options</a></div><div class="ttdoc">A set of low-level options affecting a single Flow Node, including Peer_socket objects and other obje...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00448">options.hpp:449</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_a71b56a75a4b6dba57daeef79b0b880f7"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#a71b56a75a4b6dba57daeef79b0b880f7">flow::net_flow::Node_options::m_dyn_sock_opts</a></div><div class="ttdeci">Peer_socket_options m_dyn_sock_opts</div><div class="ttdoc">The set of per-Peer_socket options in this per-Node set of options.</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00580">options.hpp:580</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_a78baaf1a911c8d490a13278422307e8a"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#a78baaf1a911c8d490a13278422307e8a">flow::net_flow::Node_options::m_st_low_lvl_max_buf_size</a></div><div class="ttdeci">size_t m_st_low_lvl_max_buf_size</div><div class="ttdoc">The max size to ask the OS to set our UDP socket's receive buffer to in order to minimize loss if we ...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00525">options.hpp:525</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_a88c732d10914f406cc43a2c20cc800c6"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#a88c732d10914f406cc43a2c20cc800c6">flow::net_flow::Node_options::m_dyn_low_lvl_max_packet_size</a></div><div class="ttdeci">size_t m_dyn_low_lvl_max_packet_size</div><div class="ttdoc">Any incoming low-level (UDP) packet will be truncated to this size.</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00553">options.hpp:553</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_abef8889be34024b07eff3211a3213d5f"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#abef8889be34024b07eff3211a3213d5f">flow::net_flow::Node_options::m_st_timer_min_period</a></div><div class="ttdeci">Fine_duration m_st_timer_min_period</div><div class="ttdoc">A time period such that the boost.asio timer implementation for this platform is able to accurately a...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00534">options.hpp:534</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_ad041b807fddff912fd6f302abeb88a2f"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#ad041b807fddff912fd6f302abeb88a2f">flow::net_flow::Node_options::m_dyn_guarantee_one_low_lvl_in_buf_per_socket</a></div><div class="ttdeci">bool m_dyn_guarantee_one_low_lvl_in_buf_per_socket</div><div class="ttdoc">This very inside-baseball setting controls the allocation/copy behavior of the UDP receive-deserializ...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00568">options.hpp:568</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Node__options_html_aea7861f3c7739f8e588293d16a2de447"><div class="ttname"><a href="structflow_1_1net__flow_1_1Node__options.html#aea7861f3c7739f8e588293d16a2de447">flow::net_flow::Node_options::m_st_capture_interrupt_signals_internally</a></div><div class="ttdeci">bool m_st_capture_interrupt_signals_internally</div><div class="ttdoc">If and only if this is true, the Node will detect SIGINT and SIGTERM (or your OS's version thereof); ...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00517">options.hpp:517</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Peer__socket__options_html_aeaaf832a38a5e334789e81e214686ea7"><div class="ttname"><a href="structflow_1_1net__flow_1_1Peer__socket__options.html#aeaaf832a38a5e334789e81e214686ea7">flow::net_flow::Peer_socket_options::m_st_max_block_size</a></div><div class="ttdeci">size_t m_st_max_block_size</div><div class="ttdoc">The size of block that we will strive to (and will, assuming at least that many bytes are available i...</div><div class="ttdef"><b>Definition:</b> <a href="options_8hpp_source.html#l00114">options.hpp:114</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Rst__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Rst__packet.html">flow::net_flow::Rst_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level RST packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l01329">low_lvl_packet.hpp:1330</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Syn__ack__ack__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Syn__ack__ack__packet.html">flow::net_flow::Syn_ack_ack_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level SYN_ACK_ACK packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l00792">low_lvl_packet.hpp:793</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Syn__ack__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Syn__ack__packet.html">flow::net_flow::Syn_ack_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level SYN_ACK packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l00678">low_lvl_packet.hpp:679</a></div></div>
<div class="ttc" id="astructflow_1_1net__flow_1_1Syn__packet_html"><div class="ttname"><a href="structflow_1_1net__flow_1_1Syn__packet.html">flow::net_flow::Syn_packet</a></div><div class="ttdoc">Internal net_flow struct that encapsulates the Flow-protocol low-level SYN packet.</div><div class="ttdef"><b>Definition:</b> <a href="low__lvl__packet_8hpp_source.html#l00583">low_lvl_packet.hpp:584</a></div></div>
<div class="ttc" id="autil__fwd_8hpp_html_a0cc4c82ac54e53b7a8a2431b66ff30df"><div class="ttname"><a href="util__fwd_8hpp.html#a0cc4c82ac54e53b7a8a2431b66ff30df">FLOW_UTIL_WHERE_AM_I_STR</a></div><div class="ttdeci">#define FLOW_UTIL_WHERE_AM_I_STR()</div><div class="ttdoc">Same as FLOW_UTIL_WHERE_AM_I() but evaluates to an std::string.</div><div class="ttdef"><b>Definition:</b> <a href="util__fwd_8hpp_source.html#l00971">util_fwd.hpp:971</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Mar 28 2025 22:55:35 for Flow by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>
